On Saturday, 22 June 2013 at 13:48:53 UTC, Andrej Mitrovic wrote:
On 6/22/13, Andrej Mitrovic <[email protected]> wrote:
    Appender!(int[]) buffer;
    call(buffer);
    writeln(buffer.data);  // writes [], it's empty

Apparently it's the same thing as the old AA problem. Essentially the
buffer would have to be initialized first by appending:

Yeah... same old, same old.

I think you can work around the problem using "appender":
auto buffer = appender!(int[])();

This is off memory, so not 100% guaranteed, but I remember this worked for me last time *I* ran into this problem.

Indeed, this is a recurring problem in D with non-initialized reference types, AA's, Appender, Containers...

The fact there is no standardized way to make a call for run-time intialization with no arguments doesn't help either. I had made a request for having an explicit runtime constructor that takes no arguments:
http://forum.dlang.org/thread/[email protected]
Didn't really get anywhere though...

In any case, I think this is a ***HUGE*** problem for D (my N°1 problem anyways). static opCall() kind of helps, but it's not quite a constructor...

I think we're kind of doomed to keep this issue around unresolved, biting users in the ass *everyday*, for still quite some time :(

Reply via email to