digitalmars.D.announce - DMD 1.014 release
- Walter Bright (5/5) Apr 27 2007 Sports associative array literals, and struct literals. This enables
- Sean Kelly (3/6) Apr 27 2007 Nice work!
- eao197 (7/11) Apr 27 2007 Wow! Thanks!
- bobef (7/14) Apr 27 2007 this class member:
- Frits van Bommel (8/20) Apr 27 2007 I guess that's what this sentence in the docs means:
- bobef (2/24) Apr 27 2007
- Don Clugston (27/50) Apr 27 2007 In practice, you _can_ have initialized static AAs, provided they are
- BCS (4/19) Apr 27 2007 function call overhead on every use? Ouch!!
- Chris Nicholson-Sauls (9/31) Apr 27 2007 Which reminds me of an ancient enhancement request idea: allow the prese...
- Georg Wrede (14/30) May 06 2007 This certainly looks like it could become an idiom! In that case I might...
- renoX (15/41) Apr 27 2007 One thing I don't understand is why this restriction on static
- torhu (4/6) Apr 27 2007 I'm sure it's been suggested before, but would this work?
- Don Clugston (2/9) Apr 27 2007 Woohoo!! Thanks, Walter. This is gonna be fun.
- Tom (6/13) Apr 27 2007 Bugzilla 1189: Reverse the titles on web pages
- Frits van Bommel (3/15) Apr 27 2007 As mentioned before, the new docs don't seem to have been uploaded to
- Tom (2/18) Apr 27 2007 Oh, sorry, I see.
- Jarrett Billingsley (12/17) Apr 27 2007 Yay for struct literals, but now static and dynamic initialization of
- Jarrett Billingsley (3/6) Apr 30 2007 Do you have _any_ thoughts on this?
- Bill Baxter (63/74) Apr 30 2007 I like your suggestion better. Walter's way takes us back to the
- Jarrett Billingsley (8/24) Apr 30 2007 I thought about that too. It just doesn't seem like a very compelling
- Pragma (6/13) Apr 27 2007 Fantastic! Thanks Walter!
- BCS (5/22) Apr 27 2007 This is what I'm waiting for:
- Pragma (5/31) Apr 27 2007 Apart from sheer curiosity, or for bragging rights, why would you want t...
- BCS (4/17) Apr 27 2007 who said anything about just the backend? I'm thinking do the whole thin...
- Pragma (9/30) Apr 27 2007 Pragma: This is madness!
- Tom S (7/14) Apr 27 2007 Must ... resist... the temptation... arrghth I love it! :D <3 *fluffles*...
- Clay Smith (3/10) Apr 27 2007 I probably don't say this enough: Thanks!
- F (2/9) Apr 27 2007
- kenny (2/15) Apr 28 2007 Walter's Freudian slip :) secret message to those that understand...
- Bruno Medeiros (8/8) May 01 2007 Is anyone interested in diffs of the D Docs between releases? I usually
- Bruno Medeiros (11/18) May 01 2007 "If any of the keys or values in the KeyValuePairs are an
- Frits van Bommel (21/38) May 01 2007 I hadn't tried yet, but I just did:
- Walter Bright (2/4) May 01 2007 It isn't a bug, though I'm not sure what utility it has.
- Frits van Bommel (9/14) May 01 2007 I'd prefer it if it wasn't allowed. It would probably catch
- gareis (5/8) May 13 2007 When you create invariants, will we be able to use associative array
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
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
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.htmlDate of D.1.014 release is 2007.04.20 in ChangeLog. -- Regards, Yauheni Akhotnikau
Apr 27 2007
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
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
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
Frits van Bommel 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]); } } 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.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
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
BCS wrote:Don Clugston wrote: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-SaulsIn 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
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
Frits van Bommel a écrit :bobef wrote: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.. renoXthis 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
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
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.zipWoohoo!! Thanks, Walter. This is gonna be fun.
Apr 27 2007
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.zipBugzilla 1189: Reverse the titles on web pages Perhaps you miss to reverse the titles on phobos docs? -- Tom; (Tomás Rossi)
Apr 27 2007
Tom wrote:Walter Bright escribió: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).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.zipBugzilla 1189: Reverse the titles on web pages Perhaps you miss to reverse the titles on phobos docs?
Apr 27 2007
Frits van Bommel escribió:Tom wrote:Oh, sorry, I see.Walter Bright escribió: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).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.zipBugzilla 1189: Reverse the titles on web pages Perhaps you miss to reverse the titles on phobos docs?
Apr 27 2007
"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.zipYay 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
"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
Jarrett Billingsley wrote:"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message news:f0svs3$1u13$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. 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. --bbIs 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
"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 literalsI 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
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.zipFantastic! Thanks Walter! ::places ear to ground:: Yep. It's a stampede alright... code generators. Lots of 'em. -- - EricAnderton at yahoo
Apr 27 2007
Pragma wrote:Walter Bright wrote:This is what I'm waiting for: import comp.time.comp; pragma(msg, D2ELF!(import("your_code.d"));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.zipFantastic! Thanks Walter! ::places ear to ground:: Yep. It's a stampede alright... code generators. Lots of 'em.
Apr 27 2007
BCS wrote:Pragma wrote: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 yahooWalter Bright wrote:This is what I'm waiting for: import comp.time.comp; pragma(msg, D2ELF!(import("your_code.d"));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.zipFantastic! Thanks Walter! ::places ear to ground:: Yep. It's a stampede alright... code generators. Lots of 'em.
Apr 27 2007
Pragma wrote:BCS wrote:that and perversity about sums it upimport 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?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
BCS wrote:Pragma wrote:Pragma: This is madness! BCS: No. This, is metaprogramming! BCS: *kick*BCS wrote:that and perversity about sums it upimport 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?who said anything about just the backend? I'm thinking do the whole thing!!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
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
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.zipI probably don't say this enough: Thanks! ~ Clay
Apr 27 2007
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
F wrote:Why the release date is shown as Apr 20, 2007 (on the changelog web page)? A typo? Walter Bright Wrote:Walter's Freudian slip :) secret message to those that understand...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 28 2007
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
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
Bruno Medeiros wrote:Walter Bright wrote: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...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.
May 01 2007
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
Walter Bright wrote:Frits van Bommel wrote: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).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
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