DMD 1.014 release

renoX renosky at free.fr
Fri Apr 27 13:59:08 PDT 2007


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



More information about the Digitalmars-d-announce mailing list