On Sunday, 3 August 2014 at 18:37:48 UTC, Sönke Ludwig wrote:
Am 03.08.2014 17:34, schrieb Andrei Alexandrescu:
6. Address w0rp's issue with undefined. In fact std.Algebraic
does have
an uninitialized state :o).
My requirements would be the same, except for 6.
The "undefined" state in the vibe.d version was necessary due
to early API decisions and it's more or less a prominent part
of it (specifically because the API was designed to behave
similar to JavaScript). In hindsight, I'd definitely avoid
that. However, I don't think its existence (also in the form of
Algebraic.init) is an issue per se, as long as such values are
properly handled when converting the runtime value back to a
JSON string (i.e. skipped or treated as null values).
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. A minor issue is being able to create a
Json object which isn't a valid Json object by itself. I'd rather
the initial value was just 'null', which would match how pointers
and class instances behave in the language.