On 4/22/2016 11:42 AM, Quim Calpe wrote: > IMHO, the point of Optional types is the intention, if you get an > Option<Foo> from a method, you have to deal with a None branch. Of course > you can just unwrap and go on, but it's a developer decision to do that, > not an oversight as using a Foo|null (or ?Foo) as an object directly. >
IMOH, the point of ?T is the intention, if you get a null from a method, you have to deal with a null branch. Of course you can just ignore it and go on, but it's a developer decision to do that, not an oversight as using a Option<T> as an object directly. Sorry, but this works in both directions. The problem is not null, the problem is that there is no system that warns you (e.g. a compiler) about the missing null check. I think that Ceylon solved this problem extremely nicely without the introduction of something special. function fn(): ?T {} $x = fn(); if (is $x T) {} else {} Not doing as above is a compiler error in Ceylon. However, I already wrote multiple times that there are already statical code analysis tools available that can find exactly such things in your code. One just needs to use them. -- Richard "Fleshgrinder" Fussenegger
signature.asc
Description: OpenPGP digital signature