Thread overview | |||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
April 27, 2007 DMD 1.014 release | ||||
---|---|---|---|---|
| ||||
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 |
April 27, 2007 Re: DMD 1.014 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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
|
April 27, 2007 Re: DMD 1.014 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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 |
April 27, 2007 Re: DMD 1.014 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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 |
April 27, 2007 Re: DMD 1.014 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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.
|
April 27, 2007 Re: DMD 1.014 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to bobef | 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. |
April 27, 2007 Re: DMD 1.014 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frits van Bommel | 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.
|
April 27, 2007 Re: DMD 1.014 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to bobef | > 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.
|
April 27, 2007 Re: DMD 1.014 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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)
|
April 27, 2007 Re: DMD 1.014 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tom | 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).
|
Copyright © 1999-2021 by the D Language Foundation