std.jgrandson
Wyatt via Digitalmars-d
digitalmars-d at puremagic.com
Mon Aug 4 06:56:50 PDT 2014
On Sunday, 3 August 2014 at 15:14:43 UTC, Andrei Alexandrescu
wrote:
> On 8/3/14, 2:38 AM, Sönke Ludwig wrote:
>> 3. Use of "opDispatch" for an open set of members has been
>> criticized for vibe.data.json before and I agree with that
>> criticism. The only advantage is saving a few keystrokes
>> (json.key instead of json["key"]), but I came to the conclusion
>> that the right approach to work with JSON values in D is to
>> always directly deserialize when/if possible anyway, which
>> mostly makes this is a moot point.
>
> Interesting. Well if experience with opDispatch is negative then
> it should probably not be used here, or only offered on an
> opt-in basis.
>
I suspect that depends on the circumstances. I've been using
this style (with Adam's jsvar), and I find it quite nice for
decomposing my TOML parse trees to Variant-like structures that
go several levels deep. It makes reading (and, consequently,
reasoning about) them much easier for me.
That said, I think the ideal would be that nesting Variant[]
should work predictably such that users can just write a one-line
opDispatch if they want it to behave that way.
-Wyatt
More information about the Digitalmars-d
mailing list