dmd 1.057 and 2.041 release

Ary Borenszweig ary at esperanto.org.ar
Mon Mar 8 05:37:35 PST 2010


Walter Bright wrote:
> Lots of meat and potatoes here, and a cookie! (spelling checker for 
> error messages)
> 
> http://www.digitalmars.com/d/1.0/changelog.html
> http://ftp.digitalmars.com/dmd.1.057.zip
> 
> 
> http://www.digitalmars.com/d/2.0/changelog.html
> http://ftp.digitalmars.com/dmd.2.041.zip
> 
> Thanks to the many people who contributed to this update!

bearophile must be very happy :-)

- Add !in operator.
- opCast(bool) and implicit call in if

But I don't like this: "This only happens, however, for instances of 
structs. Class references are converted to bool by checking to see if 
the class reference is null or not."

When I do:

if (x) {
}

I'm normally interested to enter the if branch if x is not null and it 
has an interesting value. For example, if I implement a String class I 
would implement it as not being empty. But I think the biggest problem 
is making a different semantic for this to structs and classes. You'll 
have programmers wondering why the if branch was entered even if my 
class implemented opBool not to enter it. But time will tell.

For opCast maybe it would be better to have some examples, like:

T opCast(T)() if (is(T == bool)) {
}

T opCast(T)() if (is(T == int)) {
}

(it's not very intuitive that I have to do that to implement opCast, 
it's different from the other operator overloading that rely on strings)

But very cool that opCast to many different types is implemented! :-)


More information about the Digitalmars-d-announce mailing list