When are associative arrays meant to throw a RangeError?

Ben Davis entheh at cantab.net
Sat Feb 18 15:11:17 PST 2012

To be clear, I'm not too bothered how associative arrays work. My 
proposal was merely a means by which the following currently working code:


could continue to work without relying on a current implementation 

If you want to change it not to work and make people's existing code 
crash, you can :)

On 18/02/2012 23:08, Ben Davis wrote:
> On 18/02/2012 22:57, Andrej Mitrovic wrote:
>> Are you familiar with cases where you want regular arrays to return
>> Type.init when you go out of bounds?
> The front page says D isn't meant to be an orthogonal language :P
> If you want orthogonality, then associative arrays will have to work
> something like this:
> int[string] stuff;
> stuff.addKey("a");
> stuff.addKey("b");
> stuff.addKey("d");
> stuff.addKey("e");
> stuff["a"]=0;
> stuff["b"]=1;
> stuff["c"]=2; //error
> writefln("%s",stuff["d"]);
> writefln("%s",stuff["e"]);
> writefln("%s",stuff["f"]); //error
> Do you want to do that?

More information about the Digitalmars-d mailing list