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

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 17 07:39:31 PST 2016


On 2016-12-13 23:33, Andrei Alexandrescu wrote:
> Destroy.
>
> https://github.com/dlang/DIPs/pull/51/files

A couple of questions.

1. The text says:

"void process(File input) import (std.stdio);

With this syntax, the import is executed only if the declared name is 
actually looked up."

Is "declared name" referring to the function "process"? To me it sounds 
like it could be misinterpreted to refer to "File", which would indicate 
the import is lazily executed.

2. The text says:

"Currently inline imports do not apply to alias declarations, enumerated 
types declarations, or variable declarations"

What's the reasoning behind this?

3. Is it required to place the import after the declaration or can it be 
placed in front of it?

4. Related to the third question. Would it be better (if not already) to 
implement the import as an attribute, which would allow for a more 
flexible syntax:

void process(File input) import (std.stdio);
import (std.stdio) void process(File input);

import (std.stdio)
{
     void process(File input);
     void process2(File input);
}

import (std.stdio):

void process(File input);
void process2(File input);

5. About the original syntax that was used, i.e. 
"import.std.range.isInputRange!Range". That syntax could require to 
always use a colon to separate the module name from the imported symbol. 
It's the same syntax as a selective import, which I think fits since 
with this syntax it will always be selective imports, as far as I 
understand. Example:

void process(import.std.stdio:File input);

This syntax could also be extended to all symbols:

void process(import.std.stdio:File input)
{
     import.std.stdio:File a = input;
}

6. Not sure if it's a requirement for a DIP but I don't see any formal 
description of the necessary grammar changes.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list