Skip to content
Snippets Groups Projects
Commit 13b0c3f3 authored by stepan's avatar stepan
Browse files

Reference counting for list elements

Lists can hold elements that are not in a consistent state with respect to the sharing model.
However, such elements are put into consistent state once they are read from the list, their
state can be inferred from the state of the owning list.

This means that temporary elements can be freely put into lists without incrementing their ref-count.
Moreover, when a list is copied into another variable or passed as an argument to a function,
we only have to increment the ref-count of the list (no recursion needed).

When accessing an element of a list, one should use ExtractListElement node, which handles
the transition to consistent state. This must be used wherever the state matters: when returning
the value as a result of a builtin, putting it into another list, putting it as an attribute, etc.
On the other hand, when one only wants to peek at the value, but then forget the reference,
it is OK to get it directly using getDataAt and similar methods.
parent 99639506
No related branches found
No related tags found
No related merge requests found
Showing
with 266 additions and 37 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment