std.data.json formal review

Nick Sabalausky via Digitalmars-d digitalmars-d at puremagic.com
Sat Aug 22 13:08:32 PDT 2015


On 08/21/2015 12:29 PM, David Nadlinger wrote:
> On Friday, 21 August 2015 at 15:58:22 UTC, Nick Sabalausky wrote:
>> It also fucks up UFCS, and I'm a huge fan of UFCS.
>
> Are you saying that "import json : parseJSON = parse;
> foo.parseJSON.bar;" does not work?
>

Ok, fair point, although I was referring more to fully-qualified name 
lookups, as in the snippet I quoted from Jacob. Ie, this doesn't work:

someJsonCode.std.json.parse();

I do think though, generally speaking, if there is much need to do a 
renamed import, the symbol in question probably didn't have the best 
name in the first place.

Renamed importing is a great feature to have, but when you see it used 
it raises the question "*Why* is this being renamed? Why not just use 
it's real name?" For the most part, I see two main reasons:

1. "Just because. I like this bikeshed color better." But this is merely 
a code smell, not a legitimate reason to even bother.

or

2. The symbol has a questionable name in the first place.

If there's reason to even bring up renamed imports as a solution, then 
it's probably falling into the "questionably named" category.

Just because we CAN use D's module system and renamed imports and such 
to clear up ambiguities, doesn't mean we should let ourselves take 
things TOO far to the opposite extreme when avoiding C/C++'s "big long 
ugly names as a substitute for modules".

Like Walter, I do very much dislike C/C++'s super-long, 
super-unambiguous names. But IMO, preferring parseStream over 
parseJSONStream isn't a genuine case of avoiding C/C++-style naming, 
it's just being overrun by fear of C/C++-style naming and thus taking 
things too far to the opposite extreme. We can strike a better balance 
than choosing between "brief and unclear-at-a-glance" and "C++-level 
verbosity".

Yea, we CAN do "import std.json : parseJSONStream = parseStream;", but 
if there's even any motivation to do so in the first place, we may as 
well just use the better name right from the start. Besides, those who 
prefer ultra-brevity are free to paint their bikesheds with renamed 
imports, too ;)



More information about the Digitalmars-d mailing list