Multiple distinct objects: Difference between revisions
Content added Content deleted
Line 878: | Line 878: | ||
Phix uses shared reference counts with copy-on-write semantics. Creating n references to the same mutable object is in fact the norm, |
Phix uses shared reference counts with copy-on-write semantics. Creating n references to the same mutable object is in fact the norm, |
||
but does not cause any of the issues implicitly feared in the task description. In fact, it is not possible to create shared references |
but does not cause any of the issues implicitly feared in the task description. In fact, it is not possible to create shared references |
||
such that when one is updated they all are, |
such that when one is updated they all are, instead store an index to another table that stores the object, rather than the object itself. Also, apart from low-level trickery and interfacing to shared libraries, there are no pointers to normal hll objects. Sequences need not be homogeneous, they can contain any type-mix of elements. |
||
than the object itself. Also, apart from low-level trickery and interfacing to shared libraries, there are no pointers to normal hll objects. Finally, sequences need not be homogeneous. |
|||
<lang Phix>sequence s = repeat("x",3*rand(3)) |
<lang Phix>sequence s = repeat("x",3*rand(3)) |
||
?s |
?s |
||
Line 895: | Line 894: | ||
{"xy",{"xy","x","x","x","x",5},"x","x","x",5} |
{"xy",{"xy","x","x","x","x",5},"x","x","x",5} |
||
</pre> |
</pre> |
||
I suppose it is possible that someone could write |
|||
<lang Phix>sequence s = repeat(my_func(),5)</lang> |
|||
and expect my_func() to be invoked 5 times, but for that you need a loop |
|||
<lang Phix>sequence s = repeat(0,5) |
|||
for i=1 to length(s) do |
|||
s[i] = my_func() |
|||
end for</lang> |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |