[Issue 1869] Semantically returning an array from a funciton is difficult
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 26 08:53:45 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1869
------- Comment #15 from andrei at metalanguage.com 2008-02-26 10:53 -------
(In reply to comment #14)
> Thanks for the comments, it's more or less as I suspected. The ways of
> returning an arrays pointed out by Janice Caron and others seem to feel like a
> 'workaround' to me.
>
> I don't quite understand why the code below does not (or cannot work). The pass
> by reference semantics of arrays don't have to apply for function return do
> they? It might create a special case though I suppose.
>
>
> int[4][4] f()
> {
> int a[4][4];
> return a;
> }
This will work. We'll also pass arrays in by value, and will bind literals to
dynamically-sized arrays.
In response to Derek: this is the "right thing" because every type in D has the
same copy semantics whether it sits inside a struct or not. Every type...
except statically-sized arrays.
--
More information about the Digitalmars-d-bugs
mailing list