DMD 0.163 release

Kirk McDonald kirklin.mcdonald at gmail.com
Tue Jul 18 18:54:59 PDT 2006


clayasaurus wrote:
> Walter Bright wrote:
> 
>>
>> http://www.digitalmars.com/d/changelog.html
>>
>> This has all the new import changes in it. That breaks a lot of 
>> existing code (like dmdscript), the fixes are simple (adding more 
>> import declarations) but tedious.
>>
>> I couldn't find a better keyword choice than "static import".
>>
>> The renaming uses '=' instead of 'as', 'from', or 'alias' for the 
>> reasons:
>>
>> 1) didn't want to add new keywords, especially ones like 'as' as I use 
>> that as a variable name
>>
>> 2) didn't need to add new keywords - adding them should be done only 
>> if using punctuation is completely unappealing
>>
>> 3) using '=' and ':' is visually more distinct than embedded keywords.
> 
> 
> *Imports now default to private instead of public. Breaks existing code.*
> 
> Horray! :) This shouldn't break too much of my code because I already 
> use 'private import' everywhere.
> 
> *Object.opCmp now throws an error. Should override it if used. Breaks 
> existing code.*
> 
> Can someone spell this out for me? *confused*
> 

If you write a class that does not override "opCmp", it is now a runtime 
error to attempt to compare instances of it:

class A { }

void main() {
     A a = new A;
     A b = new A;
     if (a < b) { // Error is thrown
         // ...
     }
}

Previously, the base Object class defined opCmp to compare the addresses 
in memory of the two instances (or something like that). Thus, it 
worked, but did nothing particularly useful, except insofar as "opCmp" 
always compared /something/. (This can be useful when writing, e.g. some 
templated container classes.) I think this is probably a good change.

> *Added static imports, renamed imports, and selective importing.*
> 
> Can someone show me how this is supposed to work as well? *confused*
> 

The best explanation is in the spec:
http://www.digitalmars.com/d/module.html#ImportDeclaration

On a slightly related note, I have updated my keyword index with the new 
meaning of "static":
http://www.prowiki.org/wiki4d/wiki.cgi?LanguageSpecification/KeywordIndex

> 
> Thanks! Nice to see some positive changes.
> 
> ~ Clay
> 

-- 
Kirk McDonald
Pyd: Wrapping Python with D
http://dsource.org/projects/pyd/wiki



More information about the Digitalmars-d-announce mailing list