Jonathan Blow demo #2

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 11 13:48:48 PST 2014


Walter Bright:

>> struct Vec { float x = 1, y = 5, z = 9; }
>>
>> auto v = new Vec(void);
>> auto av = new Vec[10] = void;
>> auto av2 = new Vec[10] = Vec(0, 0, 0);
>
> D already does this.

D doesn't do that, not even one of those three :-) I'm willing to 
open one or two ERs later on those things.

At best in Phobos we have a workaround for the second of those 
three ideas:

auto av = minimallyInitializedArray(Vec, 10);


>> He suggests a way to optionally specify the type of array 
>> indexes. In a D-like
>> syntax it could be:
>>
>> enum N = 10;
>> float[N : ushort] a1;
>> float[: ushort] a2;
>
> I don't see any point to this.
>
>
>> My point of having this in D is to optionally increase 
>> strictness of the array
>> indexes, to avoid some bugs when you handle many arrays.
>
> Doesn't make sense to me.

I explained the topic here (note this not exactly the same thing 
discussed by Jonathan Blow:
http://forum.dlang.org/thread/qilkslpfwvkbqlradhit@forum.dlang.org

Bye,
bearophile


More information about the Digitalmars-d mailing list