std.jgrandson

via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 4 02:24:02 PDT 2014


On Sunday, 3 August 2014 at 19:54:12 UTC, Sönke Ludwig wrote:
> Am 03.08.2014 20:57, schrieb w0rp:
>> My issue with is is that if you ask for a key in an object 
>> which doesn't
>> exist, you get an 'undefined' value back, just like 
>> JavaScript. I'd
>> rather that be propagated as a RangeError, which is more 
>> consistent with
>> associative arrays in the language and probably more correct.
>
> Yes, this is what I meant with the JavaScript part of API. In 
> addition to opIndex(), there should of course also be a 
> .get(key, default_value) style accessor and the "in" operator.

There is a parallel discussion about the concept of associative 
ranges:
http://forum.dlang.org/thread/jheurakujksdlrjaoncs@forum.dlang.org

Maybe you could also have a look there, because JSON seems to be 
a good candidate for an associative range.


More information about the Digitalmars-d mailing list