The philosophy of Nothing

Paul Benedict pbenedict at
Sun Nov 29 22:41:33 PST 2009


Thank you for your patience. Is this use case any different than 
reflection or dynamic languages? It sounds like the "Nothing" type 
returns an Object and automatic casting is performed. So why don't we 
just use Object as the return value and force a cast?


On 11/30/2009 12:33 AM, tronicek at wrote:
> They should compile because Nothing (the type inferred) is a subtype of
> Integer and String.
> If the type inferred was void, they should not have compiled.
> So, Nothing enables the compiler to check types as it does in any other
> cases.
> Another example:
> static<T>  T m(#T() p) {
>    return p.invoke();
> }
> Integer i = m(#() { throw new AssertionError(); });
> String s = m(#() { throw new AssertionError(); });
> new ArrayList().add(#() { throw new AssertionError(); });
> Z.

More information about the coin-dev mailing list