A bug in my code

Bill Baxter wbaxter at gmail.com
Sun Sep 7 18:30:59 PDT 2008


On Mon, Sep 8, 2008 at 8:33 AM, bearophile <bearophileHUGS at lycos.com> wrote:
> Jarrett Billingsley:
>> There's no way to do it with any heap-allocated value, which does seem
>> a bit like a hole to me.
>
> I think there's both a syntax problem (what syntax to use?), and the fact that when possible D wants to avoid programming mistakes, so it wants to initialize memory to a clean state (this is even more important for the GC).
>
> A first possible syntax?
> auto a = new int[10] = void;
>
> That syntax is also usable to replace this:
> auto a = new int[10];
> a[] = 5;
>
> With:
> auto a = new int[10] = 5;

My first thought was something more like

  auto a = new int(5)[10];

to init to 5, or

  auto a = new int(void)[10];

to not init.


> But maybe this isn't important enough.

Yeh, maybe not this one thing.  But enough grains of sand like this
and you have a sizable obstacle.  And D has a fair number of such
grains.

--bb


More information about the Digitalmars-d-learn mailing list