Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7639 views
1
Reference counting uses special words in functions to make it easy to remember
2
and follow the rules.
3
4
Words that take ownership: new, find, load, open, keep.
5
6
Words that release ownership: drop, free, close.
7
8
If an object is returned by a function with one of the special words that take
9
ownership, you are responsible for freeing it by calling "drop" or "free", or
10
"close" before you return. You may pass ownership of an owned object by return
11
it only if you name the function using one of the special words.
12
13
Any objects returned by functions that do not have any of these special words,
14
are borrowed and have a limited life time. Do not hold on to them past the
15
duration of the current function, or stow them away inside structs. If you need
16
to keep the object for longer than that, you have to either "keep" it or make
17
your own copy.
18
19