Passing dynamic arrays

spir denis.spir at gmail.com
Mon Nov 8 11:01:13 PST 2010


On Mon, 08 Nov 2010 19:04:40 +0100
Daniel Gibson <metalcaedes at gmail.com> wrote:

> IMHO passing arrays to functions are really inconsistent in D2 anyway:
> static arrays are passed by value but dynamic arrays are passed by reference,
> but then again, as this thread shows, not really..

It may be better to have 2 kinds of "sequences", one having true value semantics (assignment & parameter passing also protect the content), the other true reference semantics (say, an array-list). Static arrays may just be considered as an additional hint to the compiler for possible optimization.
Or, have arrays implement true value semantics, but pass them as ref when needed. But then, we may sometimes need assignment not to copy...
What do you think?

Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d mailing list