DIP10005: Dependency-Carrying Declarations is now available for community feedback

Yuxuan Shui via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 14 18:54:11 PST 2016


On Thursday, 15 December 2016 at 01:59:33 UTC, Timothee Cour 
wrote:
> how about this:
>
> variant 1 // currently legal D; just need to attach semantics
>
> ```
> // applies to all below
> @deps!({import std.stdio; pragma(lib, "curl"); }):
>
> // applies to 1 below
> @deps!({import std.range})
> void fun(T)(isInputRange!T){} // depends on both deps
>
> void fun2(File file){}  // depends on 1st deps ending with ':'
>
> ```
>
> variant 2: //currently legal if not ending with ':' as above; 
> less noisy
> syntax
> @deps{import std.stdio; pragma(lib, "curl"); }
> @deps{import std.stdio; pragma(lib, "curl"); }: // applies to 
> all below
>
> Advantages:
>
> * no new syntax (just new semantics)
> * no nesting inside {}
> * allows grouping multiple declarations under a single set of 
> imports
> * `grep import` will still work unlike many of the existing 
> proposals
> * can use existing traits to query for such imports (eg 
> getSymbolsByUDA)
> * allows a more general solution (eg also handles `pragma(lib, 
> "curl");` if
> we want that as well)

Really nice idea! Except it's still a little noisy. I would be 
really happy if this gets accepted...



More information about the Digitalmars-d mailing list