Pointers and references: Difference between revisions

Content deleted Content added
m Added bc and dc to list of omissions
Added zkl
Line 1,093:
V:= Ptr(-1); \get item immediately preceding Array(1), i.e. Array(0)
]</lang>
 
=={{header|zkl}}==
Pointers don't exist and neither do conventional references but mutable containers can act like references: List, Ref (strong reference), GarbageMan.WeakRef (weak reference) and others.
<lang zkl>fcn f(r){r.inc()} r:= Ref(1); f(r); r.value; //-->2</lang>
A Ref can hold any value. inc is a special case convenience for numbers.
<lang zkl>fcn f(lst){lst.append(5)} f(L()); //-->L(5)</lang>
Weak refs can hold anything the garbage collect can see. You can only look at the value, not change it. If it should hold a Ref or List, you can change those. The contents of a Weak Ref will vaporize sometime after the contents are no longer visible.
 
 
{{omit from|bc|No pointers/references in bc}}