On Mon, 20 Jan 2014 11:35:10 -0500, Dmitry Olshansky
<dmitry.o...@gmail.com> wrote:
19-Jan-2014 20:18, monarch_dodra пишет:
My usecase is pretty trivial: A linked list. This is often implemented
as a "single" sentinel that serves as both pre-head/post-tail. When the
list is empty, the sentinel simply points to itself.
You could use internal pointers for this case as long as:
a) The struct will never get copied and/or moved. No pass by value, only
pointers.
b) It's out of GC control and in particular GC-allocated built-in arrays.
I think this is somewhat too general. It can be GC allocated, even
GC-array allocated. The GC will not move around your array unexpectedly
without updating the pointers.
What you cannot do is array *operations* that might copy the data for that
reference/slice. So aside from the original 'new' call, you cannot use
.dup, .idup, .length +=, ~ or ~=, .reserve.
That being said, avoiding using an array is likely to be a better choice :)
As a hint, dcollections does exactly what you want to do, and I've never
had a problem with it.
-Steve