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

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 14 06:15:50 PST 2016


On 12/14/16 5:55 AM, pineapple wrote:
> On Wednesday, 14 December 2016 at 01:53:44 UTC, Chris M. wrote:
>> How about using "imports" instead of "import"? Simple enough change,
>> and it still makes sense
>>
>> bool equal(R1, R2)
>> imports (std.range)
>> if (isInputRange!R1 && isInputRange!R2)
>> { ... }
>
> On Tuesday, 13 December 2016 at 23:03:39 UTC, Timon Gehr wrote:
>> I'd prefer syntax like (import foo.bar).baz and (import foo).bar.baz.
>> (I.e., the syntax of import expressions would closely mirror that of
>> import declarations, and would be unambiguous.)
>>
>> 2. The behaviour of aliases to import expressions should be defined
>> explicitly.
>>
>> I.e.
>>
>> alias short = import very.long.module_name;
>>
>> void foo(int i)(short.T a){ ... }
>>
>> does this import the module if foo is not instantiated?
>
> I am most in favor of making the function signature either `imports` or
> `@imports`, or doing this:

No inflections please. Walter requires the use of the "import" keyword, 
and I agree with him.

> struct Buffer(R) if (import std.range:isInputRange!R) { ... }
>
> I also think actually being able to write `alias short = import
> very.long.module_name;` would be great, if only so that the contents of
> a module can be imported into their own user-defined namespace rather
> than the global scope.

The alias fails to meet the DCD principle: the declaration carries 
dependencies with it.


Andrei



More information about the Digitalmars-d mailing list