A few simple syntactic proposals

Christopher Wright dhasenan at gmail.com
Thu Apr 17 05:27:16 PDT 2008


Robert Fraser wrote:
> 1. Remove "delete aa[key]" as a syntactic equivalent to "aa.delete(key)" 
> for associative arrays. It's been deprecated in both branches of D but 
> needs to go from D2, since it goes against the D philosophy of 
> unambiguous parsing without semantic analysis.

I don't think anyone uses the former expression anymore. It's unclear.

> 2. Allow interfaces that are not sub-interfaces of IUnknown to be 
> explicitly "delete"d.

Just make all interface variables implicitly typed Object as well. Or 
make an IObject interface that Object and all interfaces inherit from, 
then make delete take an IObject as well.

Then you can have IUnknown not inherit from IObject if you want.

> 3. String literals should be typed as dynamic arrays. This would mean 
> that "foo" would be of type invariant(char)[] not type 
> invariant(char)[3u] . Note that this would have the disadvantage of 
> requiring an explicit cast if the string literal were to be needed as a 
> static array, but how many times have you actually used a string literal 
> to initialize a static array (or used a static array at all...?)

This is indeed annoying. IFTI gets you static array types unless you use 
[], and there was that old issue with arrays and associative arrays (and 
it still exists if you use auto).




More information about the Digitalmars-d mailing list