www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - DMD 1.014 release

reply Walter Bright <newshound1 digitalmars.com> writes:
Sports associative array literals, and struct literals. This enables 
compile time function execution to work with symbol tables (AA's) and 
user defined types.

http://www.digitalmars.com/d/changelog.html

http://ftp.digitalmars.com/dmd.1.014.zip
Apr 27 2007
next sibling parent Sean Kelly <sean f4.ca> writes:
Walter Bright wrote:
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.
Nice work! Sean
Apr 27 2007
prev sibling next sibling parent eao197 <eao197 intervale.ru> writes:
On Fri, 27 Apr 2007 11:42:22 +0400, Walter Bright  
<newshound1 digitalmars.com> wrote:

 Sports associative array literals, and struct literals. This enables  
 compile time function execution to work with symbol tables (AA's) and  
 user defined types.
Wow! Thanks!
 http://www.digitalmars.com/d/changelog.html
Date of D.1.014 release is 2007.04.20 in ChangeLog. -- Regards, Yauheni Akhotnikau
Apr 27 2007
prev sibling next sibling parent reply bobef <asd asd.asd> writes:
this class member:

static auto allsupportedfiles2=["avi":1,"mpg":1,"mpeg":1,"asf":1,"asx":1,"dat":1,"vob":1,"ifo":1,"wma":1,"wmv":1,"mov":1,"qt":1,"mp4":1,"fli":1,"rm":1,"nuv":1,"ogg":1,"ogm":1,"sdp":1,"pva":1,"roq":1,"flm":1,"cpk":1,"vivo":1,"mkv":1,"mp3":1,"mpe":1,"divx":1,"mpv":1,"m1v":1,"m2v":1,"dv":1,"m4v":1,"264":1,"mp1":1,"mp2":1,"mpa":1,"ac3":1,"m4a":1,"26l":1,"jsv":1,"wav":1/*,"rpl"*/,"flv":1];

app.d(126): Error: cannot infer type from this array initializer

static bool[char[]] allsupportedfiles2=["avi":1,"mpg":1,"mpeg":1,"asf":1,"asx":1,"dat":1,"vob":1,"ifo":1,"wma":1,"wmv":1,"mov":1,"qt":1,"mp4":1,"fli":1,"rm":1,"nuv":1,"ogg":1,"ogm":1,"sdp":1,"pva":1,"roq":1,"flm":1,"cpk":1,"vivo":1,"mkv":1,"mp3":1,"mpe":1,"divx":1,"mpv":1,"m1v":1,"m2v":1,"dv":1,"m4v":1,"264":1,"mp1":1,"mp2":1,"mpa":1,"ac3":1,"m4a":1,"26l":1,"jsv":1,"wav":1/*,"rpl"*/,"flv":1];

app.d(126): Error: cannot use array to initialize bool[char[]]


why?

Walter Bright Wrote:

 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.
 
 http://www.digitalmars.com/d/changelog.html
 
 http://ftp.digitalmars.com/dmd.1.014.zip
Apr 27 2007
parent reply Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
bobef wrote:
 this class member:
 
 static auto allsupportedfiles2=["avi":1,"mpg":1,"mpeg":1,"asf":1,"asx":1,"dat":1,"vob":1,"ifo":1,"wma":1,"wmv":1,"mov":1,"qt":1,"mp4":1,"fli":1,"rm":1,"nuv":1,"ogg":1,"ogm":1,"sdp":1,"pva":1,"roq":1,"flm":1,"cpk":1,"vivo":1,"mkv":1,"mp3":1,"mpe":1,"divx":1,"mpv":1,"m1v":1,"m2v":1,"dv":1,"m4v":1,"264":1,"mp1":1,"mp2":1,"mpa":1,"ac3":1,"m4a":1,"26l":1,"jsv":1,"wav":1/*,"rpl"*/,"flv":1];
 
 app.d(126): Error: cannot infer type from this array initializer
 
 static bool[char[]]
allsupportedfiles2=["avi":1,"mpg":1,"mpeg":1,"asf":1,"asx":1,"dat":1,"vob":1,"ifo":1,"wma":1,"wmv":1,"mov":1,"qt":1,"mp4":1,"fli":1,"rm":1,"nuv":1,"ogg":1,"ogm":1,"sdp":1,"pva":1,"roq":1,"flm":1,"cpk":1,"vivo":1,"mkv":1,"mp3":1,"mpe":1,"divx":1,"mpv":1,"m1v":1,"m2v":1,"dv":1,"m4v":1,"264":1,"mp1":1,"mp2":1,"mpa":1,"ac3":1,"m4a":1,"26l":1,"jsv":1,"wav":1/*,"rpl"*/,"flv":1];
 
 app.d(126): Error: cannot use array to initialize bool[char[]]
 
 
 why?
I guess that's what this sentence in the docs means: ===== An AssocArrayLiteral cannot be used to statically initialize anything. ===== (Note: The docs aren't up on the site yet, but you can find this in dmd/html/d/expression.html#AssocArrayLiteral) The error message could be clearer.
Apr 27 2007
next sibling parent reply bobef <asd asd.asd> writes:
Oops... My bad then, sorry.

Frits van Bommel Wrote:

 bobef wrote:
 this class member:
 
 static auto allsupportedfiles2=["avi":1,"mpg":1,"mpeg":1,"asf":1,"asx":1,"dat":1,"vob":1,"ifo":1,"wma":1,"wmv":1,"mov":1,"qt":1,"mp4":1,"fli":1,"rm":1,"nuv":1,"ogg":1,"ogm":1,"sdp":1,"pva":1,"roq":1,"flm":1,"cpk":1,"vivo":1,"mkv":1,"mp3":1,"mpe":1,"divx":1,"mpv":1,"m1v":1,"m2v":1,"dv":1,"m4v":1,"264":1,"mp1":1,"mp2":1,"mpa":1,"ac3":1,"m4a":1,"26l":1,"jsv":1,"wav":1/*,"rpl"*/,"flv":1];
 
 app.d(126): Error: cannot infer type from this array initializer
 
 static bool[char[]]
allsupportedfiles2=["avi":1,"mpg":1,"mpeg":1,"asf":1,"asx":1,"dat":1,"vob":1,"ifo":1,"wma":1,"wmv":1,"mov":1,"qt":1,"mp4":1,"fli":1,"rm":1,"nuv":1,"ogg":1,"ogm":1,"sdp":1,"pva":1,"roq":1,"flm":1,"cpk":1,"vivo":1,"mkv":1,"mp3":1,"mpe":1,"divx":1,"mpv":1,"m1v":1,"m2v":1,"dv":1,"m4v":1,"264":1,"mp1":1,"mp2":1,"mpa":1,"ac3":1,"m4a":1,"26l":1,"jsv":1,"wav":1/*,"rpl"*/,"flv":1];
 
 app.d(126): Error: cannot use array to initialize bool[char[]]
 
 
 why?
I guess that's what this sentence in the docs means: ===== An AssocArrayLiteral cannot be used to statically initialize anything. ===== (Note: The docs aren't up on the site yet, but you can find this in dmd/html/d/expression.html#AssocArrayLiteral) The error message could be clearer.
Apr 27 2007
parent reply Don Clugston <dac nospam.com.au> writes:
 Frits van Bommel Wrote:
 
 bobef wrote:
 this class member:

 static auto allsupportedfiles2=["avi":1,"mpg":1,"mpeg":1,"asf":1,"asx":1,"dat":1,"vob":1,"ifo":1,"wma":1,"wmv":1,"mov":1,"qt":1,"mp4":1,"fli":1,"rm":1,"nuv":1,"ogg":1,"ogm":1,"sdp":1,"pva":1,"roq":1,"flm":1,"cpk":1,"vivo":1,"mkv":1,"mp3":1,"mpe":1,"divx":1,"mpv":1,"m1v":1,"m2v":1,"dv":1,"m4v":1,"264":1,"mp1":1,"mp2":1,"mpa":1,"ac3":1,"m4a":1,"26l":1,"jsv":1,"wav":1/*,"rpl"*/,"flv":1];

 app.d(126): Error: cannot infer type from this array initializer

 static bool[char[]]
allsupportedfiles2=["avi":1,"mpg":1,"mpeg":1,"asf":1,"asx":1,"dat":1,"vob":1,"ifo":1,"wma":1,"wmv":1,"mov":1,"qt":1,"mp4":1,"fli":1,"rm":1,"nuv":1,"ogg":1,"ogm":1,"sdp":1,"pva":1,"roq":1,"flm":1,"cpk":1,"vivo":1,"mkv":1,"mp3":1,"mpe":1,"divx":1,"mpv":1,"m1v":1,"m2v":1,"dv":1,"m4v":1,"264":1,"mp1":1,"mp2":1,"mpa":1,"ac3":1,"m4a":1,"26l":1,"jsv":1,"wav":1/*,"rpl"*/,"flv":1];

 app.d(126): Error: cannot use array to initialize bool[char[]]


 why?
I guess that's what this sentence in the docs means: ===== An AssocArrayLiteral cannot be used to statically initialize anything. ===== (Note: The docs aren't up on the site yet, but you can find this in dmd/html/d/expression.html#AssocArrayLiteral) The error message could be clearer.
In practice, you _can_ have initialized static AAs, provided they are read-only (which is probably the main time you want to supply initializers). The declaration syntax for a read-only AA slightly lacks syntactic sugar, but the syntax for usage is perfect: char[][uint] symTable() { return [2u:"he",4:"ho",6:"hi"]; } void main() { for (int k=1; k<=6; ++k) { if ((k&1)==0) printf("%.*s\n", symTable[k]); } } BTW, these read-only AAs are great for eliminating case statements! ------------------ char [] a; switch(k) { case 2: a="he"; break; case 4: a= "ho"; break; case 6: a="hum"; break; } ------------------ becomes: ------------------ char [] a = [2:"he"[], 4:"ho", 6:"hum"][k]; ------------------ Which is pretty awesome when you have a lot of trivial cases; ought to generate better code, too.
Apr 27 2007
next sibling parent reply BCS <BCS pathlink.com> writes:
Don Clugston wrote:
 
 In practice, you _can_ have initialized static AAs, provided they are 
 read-only (which is probably the main time you want to supply 
 initializers). The declaration syntax for a read-only AA slightly lacks 
 syntactic sugar, but the syntax for usage is perfect:
 
 char[][uint] symTable() { return [2u:"he",4:"ho",6:"hi"]; }
 
 void main()
 {
     for (int k=1; k<=6; ++k) {
         if ((k&1)==0) printf("%.*s\n", symTable[k]);
     }
 }
 
function call overhead on every use? Ouch!! I'd rather go with char[][uint] symTable; static this(){symTable=[2u:"he",4:"ho",6:"hi"];}
Apr 27 2007
parent Chris Nicholson-Sauls <ibisbasenji gmail.com> writes:
BCS wrote:
 Don Clugston wrote:
 In practice, you _can_ have initialized static AAs, provided they are 
 read-only (which is probably the main time you want to supply 
 initializers). The declaration syntax for a read-only AA slightly 
 lacks syntactic sugar, but the syntax for usage is perfect:

 char[][uint] symTable() { return [2u:"he",4:"ho",6:"hi"]; }

 void main()
 {
     for (int k=1; k<=6; ++k) {
         if ((k&1)==0) printf("%.*s\n", symTable[k]);
     }
 }
function call overhead on every use? Ouch!! I'd rather go with char[][uint] symTable; static this(){symTable=[2u:"he",4:"ho",6:"hi"];}
Which reminds me of an ancient enhancement request idea: allow the presence of /multiple/ static constructors within a scope (module or class), which are later concatenated into one function body by the compiler. Then your above item becomes just one line, rather than a declaration in one place, and an initialization in the midst of a possibly longer function somewhere else entirely within the source file. (I like keeping the number of lines that have to be hit for changes small... can you tell? It makes it less likely I or someone else will make a silly mistake later.) -- Chris Nicholson-Sauls
Apr 27 2007
prev sibling parent Georg Wrede <georg nospam.org> writes:
Don Clugston wrote:
 BTW, these read-only AAs are great for eliminating case statements!
 ------------------
 char [] a;
 switch(k)
 {
 case 2: a="he"; break;
 case 4: a= "ho"; break;
 case 6: a="hum"; break;
 }
 ------------------
 becomes:
 ------------------
 char [] a = [2:"he"[], 4:"ho", 6:"hum"][k];
 ------------------
 Which is pretty awesome when you have a lot of trivial cases; ought to 
 generate better code, too.
This certainly looks like it could become an idiom! In that case I might suggest another way of writing it: char [] a = [ 2:"he"[], 4:"ho", 6:"hum" ] [k]; The latter is easier to read, especially when there are a lot of members. Problem with both is still that [k] ends up quite far from the assignment. Of course with a named AA we could write: char [] a = myReadOnlyAA [k];
May 06 2007
prev sibling parent reply renoX <renosky free.fr> writes:
Frits van Bommel a écrit :
 bobef wrote:
 this class member:

 static auto 
 allsupportedfiles2=["avi":1,"mpg":1,"mpeg":1,"asf":1,"asx":1,"dat":1,"vob":1,"ifo":1,"wma":1,"wmv":1,"mov":1,"qt":1,"mp4":1,"fli":1,"rm":1,"nuv":1,"ogg":1,"ogm":1,"sdp":1,"pva":1,"roq":1,"flm":1,"cpk":1,"vivo":1,"mkv":1,"mp3":1,"mpe":1,"divx":1,"mpv":1,"m1v":1,"m2v":1,"dv":1,"m4v":1,"264":1,"mp1":1,"mp2":1,"mpa":1,"ac3":1,"m4a":1,"26l":1,"jsv":1,"wav":1
*,"rpl"*/,"flv":1]; 


 app.d(126): Error: cannot infer type from this array initializer

 static bool[char[]] 
 allsupportedfiles2=["avi":1,"mpg":1,"mpeg":1,"asf":1,"asx":1,"dat":1,"vob":1,"ifo":1,"wma":1,"wmv":1,"mov":1,"qt":1,"mp4":1,"fli":1,"rm":1,"nuv":1,"ogg":1,"ogm":1,"sdp":1,"pva":1,"roq":1,"flm":1,"cpk":1,"vivo":1,"mkv":1,"mp3":1,"mpe":1,"divx":1,"mpv":1,"m1v":1,"m2v":1,"dv":1,"m4v":1,"264":1,"mp1":1,"mp2":1,"mpa":1,"ac3":1,"m4a":1,"26l":1,"jsv":1,"wav":1
*,"rpl"*/,"flv":1]; 


 app.d(126): Error: cannot use array to initialize bool[char[]]


 why?
I guess that's what this sentence in the docs means: ===== An AssocArrayLiteral cannot be used to statically initialize anything. ===== (Note: The docs aren't up on the site yet, but you can find this in dmd/html/d/expression.html#AssocArrayLiteral) The error message could be clearer.
One thing I don't understand is why this restriction on static assignment with AA initialisation exist? In my head, static assignment of compile time assignment is more or less equivalent, so I find this weird.. I think that there are too many special cases in D: - initialisation with literals works for normal assignment not for static - in works for AA but not for array - array initialisation count elements for dynamic arrays but not for array with fixed length. etc. Hopefully with macros it'll be possible to make D a bit more coherent (a generic call 'by keyword' a la Smalltalk would be nice), all those special cases are not fun to remember.. renoX
Apr 27 2007
parent torhu <fake address.dude> writes:
renoX wrote:
 - array initialisation count elements for dynamic arrays but not for 
 array with fixed length.
I'm sure it's been suggested before, but would this work? int[3] = [1, 2, 3]; // explicit length int[$] = [1, 2, 3]; // compiler infers length
Apr 27 2007
prev sibling next sibling parent Don Clugston <dac nospam.com.au> writes:
Walter Bright wrote:
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.
 
 http://www.digitalmars.com/d/changelog.html
 
 http://ftp.digitalmars.com/dmd.1.014.zip
Woohoo!! Thanks, Walter. This is gonna be fun.
Apr 27 2007
prev sibling next sibling parent reply Tom <tom nospam.com> writes:
Walter Bright escribió:
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.
 
 http://www.digitalmars.com/d/changelog.html
 
 http://ftp.digitalmars.com/dmd.1.014.zip
Bugzilla 1189: Reverse the titles on web pages Perhaps you miss to reverse the titles on phobos docs? -- Tom; (Tomás Rossi)
Apr 27 2007
parent reply Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Tom wrote:
 Walter Bright escribió:
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.

 http://www.digitalmars.com/d/changelog.html

 http://ftp.digitalmars.com/dmd.1.014.zip
Bugzilla 1189: Reverse the titles on web pages Perhaps you miss to reverse the titles on phobos docs?
As mentioned before, the new docs don't seem to have been uploaded to the site yet. The docs in the zip are fixed (I just checked).
Apr 27 2007
parent Tom <tom nospam.com> writes:
Frits van Bommel escribió:
 Tom wrote:
 Walter Bright escribió:
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.

 http://www.digitalmars.com/d/changelog.html

 http://ftp.digitalmars.com/dmd.1.014.zip
Bugzilla 1189: Reverse the titles on web pages Perhaps you miss to reverse the titles on phobos docs?
As mentioned before, the new docs don't seem to have been uploaded to the site yet. The docs in the zip are fixed (I just checked).
Oh, sorry, I see.
Apr 27 2007
prev sibling next sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Walter Bright" <newshound1 digitalmars.com> wrote in message 
news:f0s9gr$u05$1 digitalmars.com...
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and user 
 defined types.

 http://www.digitalmars.com/d/changelog.html

 http://ftp.digitalmars.com/dmd.1.014.zip
Yay for struct literals, but now static and dynamic initialization of structs are completely different. Static looks like this: static S s = {a : 1, b : 2, c : 3}; and dynamic: S s = S(1, 2, 3); Not only do they look completely different, but you also can't use named members with the dynamic syntax like you can with the static. Is there any ambiguity to the syntax: S s = S{a : 1, c : 3, b : 2}; That is, just an Ident followed by a static struct initializer?
Apr 27 2007
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message 
news:f0svs3$1u13$1 digitalmars.com...
 Is there any ambiguity to the syntax:

 S s = S{a : 1, c : 3, b : 2};

 That is, just an Ident followed by a static struct initializer?
Do you have _any_ thoughts on this?
Apr 30 2007
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Jarrett Billingsley wrote:
 "Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message 
 news:f0svs3$1u13$1 digitalmars.com...
 Is there any ambiguity to the syntax:

 S s = S{a : 1, c : 3, b : 2};

 That is, just an Ident followed by a static struct initializer?
Do you have _any_ thoughts on this?
I like your suggestion better. Walter's way takes us back to the error-prone, fragile, mystery-meat way of constructing structs that they tossed out in C99. Ok, not "tossed out" but "provided an alternative to." Walter's way, however, gives you a way to transition from quick and dirty usage like struct Coord{ float x; float y; } func(Coord(xval,yval)); to something more complex via static opCall. Say you realize you should have been using polar coordinates internally, then you can just add an opCall and some properties to do that: struct Coord{ float r; float theta; float x() { return r*cos(theta); } float y() { return r*sin(theta); } static Coord opCall(float x, float y) { Coord it; with(it) { r = hypot(x,y); theta = atan2(y,x); } return it; } // This still works func(Coord(xval,yval)); Not extremely realistic, because if you have a polar coord struct probably you'll want the (float,float) opCall to take (r,theta) instead of (x,y), but well, the above is the best defense of Walter's approach I could come up with. Keyword Arguments: On the other hand, it would be potentially very cool if we could write member function to override the behavior of S s = S{a:1,c:3,b:2} as well. But we need functions with keyword arguments for that to work. I think we're not so far away. If you treat a keyword function as functions of one anonymous struct then you're pretty much there. For instance this: void a_keyword_func({int a=10, int b=4, int c=20}) {. . .} a_keyword_func(c:10, a:1); could be treated as struct _S { int a=10; int b=4; int c=20; } a_keyword_func( _S ) { . . . } a_keyword_func( _S{c:10, a:1} ); //using your struct literals Not sure what to do about out/inout/ref args. That's the kicker I supposed. But I think this approach to keyword args differs from the previous proposals by myself and others in that it makes keyword functions different from regular functions. That means the programmer has to decide whether to make it a keyword function or not, but it also means fewer backwards compatibility issues. The times I've seen keyword args suggested the rejoinder was always -- if you have so many arguments then just make a struct to hold them all. Well that's exactly what this does, except it doesn't require the library desiger to litter his code and namespaces with structs that only serve the purpose of calling one function, and it doesn't make the user think about creating useless one-time structs to call that function either. It's still what happens under the hood, just no one has to think about it. I think the desire to limit the scope of such an argument struct to the function that requires it, is very similar to the desire to have inner functions. The goal is to keep information specific to a particular function local to that function. In the case of inner functions that means a function is created with a specially mangled name. In the case of these automatic parameter structs for keyword arguments, you'd have a specially mangled struct name automatically generated. --bb
Apr 30 2007
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Bill Baxter" <dnewsgroup billbaxter.com> wrote in message 
news:f161g5$2kno$1 digitalmars.com...
 I like your suggestion better.  Walter's way takes us back to the 
 error-prone, fragile, mystery-meat way of constructing structs that they 
 tossed out in C99.  Ok, not "tossed out" but "provided an alternative to."

 Walter's way, however, gives you a way to transition from quick and dirty 
 usage like
   struct Coord{ float x; float y; }
   func(Coord(xval,yval));
 to something more complex via static opCall.
I thought about that too. It just doesn't seem like a very compelling argument, especially considering that the language already has a perfectly good syntax for static struct literals.
 If you treat a keyword function as functions of one anonymous struct then 
 you're pretty much there.  For instance this:

    void a_keyword_func({int a=10, int b=4, int c=20}) {. . .}

    a_keyword_func(c:10, a:1);

 could be treated as

    struct _S { int a=10; int b=4; int c=20; }
    a_keyword_func( _S ) { . . . }

    a_keyword_func( _S{c:10, a:1} );  //using your struct literals
I like the idea. It also seems relatively unambiguous to parse. Any colon in the param list of a call would signal use of names parameters, and the compiler would be able to check the function for any named params it has.
Apr 30 2007
prev sibling next sibling parent reply Pragma <ericanderton yahoo.removeme.com> writes:
Walter Bright wrote:
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.
 
 http://www.digitalmars.com/d/changelog.html
 
 http://ftp.digitalmars.com/dmd.1.014.zip
Fantastic! Thanks Walter! ::places ear to ground:: Yep. It's a stampede alright... code generators. Lots of 'em. -- - EricAnderton at yahoo
Apr 27 2007
parent reply BCS <BCS pathlink.com> writes:
Pragma wrote:
 Walter Bright wrote:
 
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.

 http://www.digitalmars.com/d/changelog.html

 http://ftp.digitalmars.com/dmd.1.014.zip
Fantastic! Thanks Walter! ::places ear to ground:: Yep. It's a stampede alright... code generators. Lots of 'em.
This is what I'm waiting for: import comp.time.comp; pragma(msg, D2ELF!(import("your_code.d"));
Apr 27 2007
next sibling parent reply Pragma <ericanderton yahoo.removeme.com> writes:
BCS wrote:
 Pragma wrote:
 Walter Bright wrote:

 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.

 http://www.digitalmars.com/d/changelog.html

 http://ftp.digitalmars.com/dmd.1.014.zip
Fantastic! Thanks Walter! ::places ear to ground:: Yep. It's a stampede alright... code generators. Lots of 'em.
This is what I'm waiting for: import comp.time.comp; pragma(msg, D2ELF!(import("your_code.d"));
Apart from sheer curiosity, or for bragging rights, why would you want to completely re-implement the compiler backend as compile-time code? -- - EricAnderton at yahoo
Apr 27 2007
parent reply BCS <BCS pathlink.com> writes:
Pragma wrote:
 BCS wrote:
 


 import comp.time.comp;

 pragma(msg, D2ELF!(import("your_code.d"));
Apart from sheer curiosity,
that and perversity about sums it up
 or for bragging rights, why would you want 
 to completely re-implement the compiler backend as compile-time code?
 
who said anything about just the backend? I'm thinking do the whole thing!! Then again, I've been told I'm totally nuts.
Apr 27 2007
parent Pragma <ericanderton yahoo.removeme.com> writes:
BCS wrote:
 Pragma wrote:
 BCS wrote:



 import comp.time.comp;

 pragma(msg, D2ELF!(import("your_code.d"));
Apart from sheer curiosity,
that and perversity about sums it up
 or for bragging rights, why would you want to completely re-implement 
 the compiler backend as compile-time code?
who said anything about just the backend? I'm thinking do the whole thing!!
Pragma: This is madness! BCS: No. This, is metaprogramming! BCS: *kick*
 
 Then again, I've been told I'm totally nuts.
No, you (along with Don and myself) are pushing D towards it's ultimate destination: de-throning C as the language of choice for obfuscated programming contests. Jebus help us all. -- - EricAnderton at yahoo
Apr 27 2007
prev sibling parent Tom S <h3r3tic remove.mat.uni.torun.pl> writes:
BCS wrote:
 This is what I'm waiting for:
 

 
 import comp.time.comp;
 
 pragma(msg, D2ELF!(import("your_code.d"));
Must ... resist... the temptation... arrghth I love it! :D <3 *fluffles* erm... I mean.. don't do this! This is too perverted! *hides* -- Tomasz Stachowiak http://h3.team0xf.com/ h3/h3r3tic on #D freenode
Apr 27 2007
prev sibling next sibling parent Clay Smith <clayasaurus gmail.com> writes:
Walter Bright wrote:
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.
 
 http://www.digitalmars.com/d/changelog.html
 
 http://ftp.digitalmars.com/dmd.1.014.zip
I probably don't say this enough: Thanks! ~ Clay
Apr 27 2007
prev sibling next sibling parent reply F <noemail noemail.com> writes:
 Why the release date is shown as Apr 20, 2007 (on the changelog web page)? A
typo?


Walter Bright Wrote:

 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.
 
 http://www.digitalmars.com/d/changelog.html
 
 http://ftp.digitalmars.com/dmd.1.014.zip
Apr 27 2007
parent kenny <funisher gmail.com> writes:
F wrote:
  Why the release date is shown as Apr 20, 2007 (on the changelog web page)? A
typo?
 
 
 Walter Bright Wrote:
 
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.

 http://www.digitalmars.com/d/changelog.html

 http://ftp.digitalmars.com/dmd.1.014.zip
Walter's Freudian slip :) secret message to those that understand...
Apr 28 2007
prev sibling next sibling parent Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
Is anyone interested in diffs of the D Docs between releases? I usually 
do that on all releases anyway, since I want to keep up with the changes 
but some things don't go to the changelog, so I diff the docs and remove 
(most of) the HTML or otherwise redundant changes.
Here's the diff for 1.014 for example.


-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
May 01 2007
prev sibling next sibling parent reply Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
Walter Bright wrote:
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.
 
 http://www.digitalmars.com/d/changelog.html
 
 http://ftp.digitalmars.com/dmd.1.014.zip
"If any of the keys or values in the KeyValuePairs are an ExpressionTuple, then the elements of the ExpressionTuple are inserted as arguments in place of the tuple. " Can you give an example of that? I was thinking of something like: int[char[]] f; f = [ Tuple!(["one"[]:1, "two":2]) ]; but it didn't work. -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
May 01 2007
parent reply Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Bruno Medeiros wrote:
 Walter Bright wrote:
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.

 http://www.digitalmars.com/d/changelog.html

 http://ftp.digitalmars.com/dmd.1.014.zip
"If any of the keys or values in the KeyValuePairs are an ExpressionTuple, then the elements of the ExpressionTuple are inserted as arguments in place of the tuple. " Can you give an example of that? I was thinking of something like: int[char[]] f; f = [ Tuple!(["one"[]:1, "two":2]) ]; but it didn't work.
I hadn't tried yet, but I just did: --- import std.stdio; template Tuple(Ts...) { alias Ts Tuple; } void main() { // This is pretty cool: writefln([Tuple!(4,5,6) : Tuple!(-1,-2,-3)]); // outputs: [4:-1,5:-2,6:-3] // But it doesn't seem to care if the numbers of keys and values // go out-of-sync: (I wonder if this is a bug) writefln([1 : Tuple!(100, 200, 300), 111 : 222, Tuple!(2,3,4) : -400]); // outputs: [1:100,2:300,3:222,4:-400,111:200] // And the number of keys must match the number of values //writefln([1 : Tuple!(1,2)]); // Compile-time error: // "Error: number of keys is 1, must match number of values 2" } --- Like it says in the comment, I wonder if the behavior of the second one is a bug...
May 01 2007
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Frits van Bommel wrote:
 Like it says in the comment, I wonder if the behavior of the second one 
 is a bug...
It isn't a bug, though I'm not sure what utility it has.
May 01 2007
parent Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Walter Bright wrote:
 Frits van Bommel wrote:
 Like it says in the comment, I wonder if the behavior of the second 
 one is a bug...
It isn't a bug, though I'm not sure what utility it has.
I'd prefer it if it wasn't allowed. It would probably catch accidental-mismatch bugs without reducing the power of the construct. If someone actually *wants* the current behavior, they could use the implicit tuple flattening to put all keys in one tuple and all values in another. I just don't think that "[A : B, 1 : 2, C : D][1]" should be allowed to be anything other than 2 regardless of what A, B, C and D happen to be (as long as A and C aren't tuples containing the value 1).
May 01 2007
prev sibling parent gareis <dhasenan gmail.com> writes:
Walter Bright wrote:
 Sports associative array literals, and struct literals. This enables 
 compile time function execution to work with symbol tables (AA's) and 
 user defined types.
When you create invariants, will we be able to use associative array literals to instantiate invariant associative arrays? Or do you plan on making associative array literals available to instantiate all associative arrays before then?
May 13 2007