seeding the pot for 2.0 features

BCS ao at pathlink.com
Tue Jan 23 16:09:09 PST 2007


Reply to Pragma,

> First - You need some way to flag to a compiler which D version is
> being used.
> 
> 0) compiler arg that forces one version or the other for all input
> files (obvious)
> 1) use a different file extension: ".d2"
> 2) provide a pragma: "pragma(dversion,2);
> 3) abuse the version statement: "version dlanguage = 2;"
> 4) all of the above
> 5) something else

magic! {try parser(1.0, file); catch paser(2.0,file);}

> 
> void foobar(){
> static uint baz;
> static void this(){  baz = 111; }
> }
> IMO, this doesn't seem all that useful.  I would much rather have D
> allow non-static expressions for static initializers;

I think non const would be better than non static, or was that a typo?

>> 4) I guess that also needs a "implementable function alias". The
>> syntax, not to mention the name, could ues a little work, but I
>> expect you get the picture.
>> 
> You lost me here.  Care to elaborate? :)

>From the example I gave, the foreach would iterate over the members of I.tupleof 
and generate a function for each method that "I" defines. Take a look at 
my reply to kris for an example of what this would be used for. (short vertion: 
network transport of an interface)

> 
> 5) I'll contribute one more: a "true closure" syntax.  I really don't
> care keyword magic is used to make this
> work, just as long as it's less verbose than creating a class w/a
> single method to simulate the same thing.
> 

yah.

my choice: dynamic init structs and explicit context for delegates

int i,j,k;
// pickle i,j,k then use them
auto (new struct {int i_ = i; int j_ = j; int k_ = k; }).delegate(int m){return 
((i_ * m)+j_)*m +k_;}





More information about the Digitalmars-d mailing list