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

Reply via email to