[Issue 1869] Semantically returning an array from a funciton is difficult

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 25 16:59:18 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=1869





------- Comment #6 from andrei at metalanguage.com  2008-02-25 18:59 -------
The right thing to do is to manipulate fixed-sized arrays by value, but there
are a number of consequent issues to solve, e.g. we wouldn't like this:

writeln("Hello, world!");

to copy the actual content of the string on the stack and over to the callee.
Walter is considering making all array constants bind to dynamically-sized
types by default, and to statically-sized types only when explicitly requested,
e.g.:

auto x = "Hello, world!" // x is string
char[$] y = "Hello, world!" // y is char[13]
char[auto] z = "Hello, world!" // z is char[13]

The syntax is not decided between y's and z's. (Only one at most will be
chosen.) The former is better because you can then write:

auto[$] w = "Hello, world!" // w is invariant(char)[13]

whereas auto[auto] would look awkward.


Andrei


-- 



More information about the Digitalmars-d-bugs mailing list