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

Timothee Cour via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 14 17:59:33 PST 2016


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)




On Wed, Dec 14, 2016 at 4:54 PM, ketmar via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On Thursday, 15 December 2016 at 00:29:17 UTC, Chris M wrote:
>
>> For the "with" keyword, why is the import statement kept? Seems
>> unnecessary to keep it.
>>
>> void process(File input) import std.stdio;
>> struct Buffered(Range) if (isInputRange!Range)
>> with (std.range)
>> {
>>     ...
>> }
>>
>
> to not block future uses of such `with` syntax for different purposes. and
> (which is more important for me, for example) to make greping easier. and
> to keep `with` semantics: it should introduce scope over *existing* things.
> explicit `import` brings the module to the existance. choose any options
> you like. ;-)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20161214/38e3ae8d/attachment.html>


More information about the Digitalmars-d mailing list