DIP10005: Dependency-Carrying Declarations is now available for community feedback
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Tue Dec 13 17:39:01 PST 2016
On 12/13/16 8:07 PM, Chris M. wrote:
>
> Why not something like import foo.bar : baz or import foo : bar.baz to
> distinguish between module and symbol? It's already used anyway.
>
> Also I like Yuxuan's idea, the other ideas seem to add more clutter
> after the function name
So we have:
// 1
struct Buffer(R) if ((import std.range).isInputRange!R) { ... }
// 2
struct Buffer(R) if (import std.range:isInputRange!R) { ... }
// 3
@import("std.stdio") struct Buffer(R) if (isInputRange!R) { ... }
The first two require repeating the import for each separate
declaration, e.g.:
// 1
bool equal(R1, R2)
if ((import std.range).isInputRange!R1 && (import
std.range).isInputRange!R2)
{ ... }
// 2
bool equal(R1, R2)
if (import std.range:isInputRange!R1 && import std.range:isInputRange!R2)
{ ... }
The last is surprising because it uses a string where otherwise there
would be an unquoted list of dot-separated names.
I prefer the current form of the proposal:
bool equal(R1, R2)
import (std.range)
if (isInputRange!R1 && isInputRange!R2)
{ ... }
The point has been brought up that the syntax import(std.range) is also
used for string imports. It is a drawback.
Andrei
More information about the Digitalmars-d
mailing list