On 4/13/11 3:03 PM, Nick Sabalausky wrote:
"bearophile"<bearophileh...@lycos.com>  wrote in message
news:io458e$elr$1...@digitalmars.com...

Ceylon does not support method overloading (or any other kind of
overloading).


Eewww. Haxe is like that and it's nothing but a royal pain in the ass.


If a value of type T can be null, it must be declared as type Optional<T>,
which may be abbreviated to T?

String? name = process.args.first;
if (exists name) {
    writeLine("Hello " name "!");
}
else {
    writeLine("Hello World!");
}

Use of an optional value must be guarded by the if (exists ... )
construct. Therefore, NullPointerExceptions are impossible.

This is exactly what I suggested for D in a enhancement request.
It seems this kind of stuff is becoming a standard in new languages.


Yes, I'd *love* to see that in D, too.

I think you'd be hasty. As Kagamin mentioned, this ad-hoc guarding works straight against modularity. Also, without more details I can't really say, but if the type of the checked variable doesn't automagically change from T? to T inside the guarded code, a lot of subsequent uses (pass down to functions etc.) would have to repeat the check. Also, if the variable is reassigned it would have to change back the type from T to T?, which makes program understanding by both human and compiler (e.g. "do I need a test here?") a bitch.

I'm highly skeptical of this feature in particular. I'm even more so because it's the kind of ad-hoc feature with many fuzzy corners that needs solid real-world validation, which... ("You can’t write code in the language just yet!") doesn't exist.


Andrei

Reply via email to