On 2010-07-12 13:49:50 -0400, Andrei Alexandrescu <[email protected]> said:

The point is that with a delegate you must choose between accepting E and E[]. Given the constraint, it's better for everyone to accept E[] and let put() take care of the occasional E by doing the wraparoo (&elem)[0..1].

If this means what I think, it means put() cannot be memory safe. Making an array from a stack variable and passing it around cannot be safe unless you can trust this reference won't escape the scope of the delegate you're calling (and there's no way to enforce that for dynamic arrays). To be safe, all you can do is copy the element on the heap. Am I wrong?

--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to