On 12/15/2016 02:22 PM, Timothee Cour via Digitalmars-d wrote:
Some more details on my proposa based on UDA:

// applies to next decl
@deps!({import std.algorithm;})
void test1(){}

// applies to a set of decls
@deps!({import std.stdio;}){
  void test2(){}
  void test3(){}
}

// applies to all following decls (':')
@deps!({import std.array;}):

// can specify other dependencies beyond imports and have arbitrary
complex logic:
@deps!({
  import std.range;
  static int[100] data2;
  version(linux){
    enum data1=import("foo");//string import
    pragma(lib, "curl");
  }
}):
void test4(){}

// Can alias some dependencies:
alias deps1=deps!({import std.algorithm;});

@deps1
void test4(){}

NOTE: the above code compiles if we add
`struct deps(T...){}`, but that logic would be implemented in the compiler.

I now understand the idea, thank you.

My question is, doesn't this take things too far? Earlier I wrote:

The acceptability of the proposal decays exponentially with its
deviation from existing import syntax.

Indeed adding less syntax is better, but that's not an absolute; the optimum isn't necessarily at the "zero syntax added" point. This is because there are several things to harmonize in language design, which naturally are in tension.


Andrei

Reply via email to