std.data.json formal review

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 30 12:57:35 PDT 2015


On Thu, Jul 30, 2015 at 12:43:40PM -0700, Walter Bright via Digitalmars-d wrote:
> On 7/30/2015 9:58 AM, Brad Anderson wrote:
> >If we can't have the minimal necessary module paths then I'm
> >completely in favor of parseJSONStream over the more general
> >parseStream. I want that "json" in there one way or another
> >(preferably by the method which makes it optional while maintaining
> >brevity).
> 
> I would think it unlikely to be parsing two different formats in one
> file.  But in any case, you can always do this:
> 
>    import std.data.json : parseJSON = parse;
> 
> Or put the import in a scope:
> 
>    void doNaughtyThingsWithJson()
>    {
>        import std.data.json;
>        ...
>        x.parse();
>    }
> 
> The latter seems to be becoming the preferred D style.

Yeah, local imports are fast becoming my preferred D coding style,
because it makes code portable -- if you move a function to a new
module, you don't have to untangle its import dependencies if all
imports are local. It's one of those little, overlooked things about D
that contribute toward making it an awesome language.


T

-- 
Written on the window of a clothing store: No shirt, no shoes, no service.


More information about the Digitalmars-d mailing list