All right, all right! Interim decision regarding qualified Object methods

Jonathan M Davis jmdavisProg at gmx.com
Thu Jul 12 19:19:29 PDT 2012


On Friday, July 13, 2012 03:30:36 Mehrdad wrote:
> On Friday, 13 July 2012 at 01:22:59 UTC, Jonathan M Davis wrote:
> > There's big difference between a library and a the language
> > itself.
> 
> Surely that's a non sequitur... Aren't we modifying druntime here?
> What part of this has to do with the _language_? Isn't druntime a
> library?

druntime is the runtime for D. The compiler uses it to implement key aspects 
of the language (e.g. new). Without it, you don't have D. It's effectively part 
of the language. Yes, you can replace it with your own version if you want to, 
but if you do so, you're essentially make your own variant of the language.

> 2. Isn't it kinda /trivial/ to avoid opEquals? Just don't use it.
> Make up your own method. What's wrong with this?

Stuff like AAs rely on it. So yes, if opEquals, opCmp, toHash, and toString 
were all const, classes could just override them, put assert(0); as their 
bodies, and not use them, but then anything requiring those functions - 
including the built AAs and standard library stuff such as format and writeln - 
would not only not work right, but they would kill your program when they were 
used. == itself used on such an object would kill your program. So, as it 
stands, whole language features become impossible to use with classes which 
can't be implemented with those 4 functions being const. You could only use 
classes which can't be const by avoiding those language features completely.

The proposed changes would make it possible for all of those features to be 
used by programs which didn't use const.

- Jonathan M Davis


More information about the Digitalmars-d mailing list