[Grace-core] Gradual typing with Dynamic return type

Michael Homer mwh at ecs.vuw.ac.nz
Wed Sep 28 21:47:11 PDT 2011


On Thu, Sep 29, 2011 at 5:12 PM, James Noble <kjx at ecs.vuw.ac.nz> wrote:
> But {... return (dynamic) "broken" }  would work, right?
>
> Not sure that helps but I wonder if there's something there...
Yes, with a runtime check. dynamic is treated as equivalent to object,
and compiled to it, but inserts downcasts where required (there is
also a protocol for method dispatch on dynamic itself). For
declarations, though, the return type of an overriding method must be
a subtype of the declared return type in the superclass, and dynamic
is not a subtype of anything.

> It would also be possible to compile more than one entry point for each method - or even just have one extra-slow "dispatch" point for each object.
>
> Once you're tainted with dynamic, off to slow land you go
That's possible, but I'm not sure it solves all the issues. I suppose
that if it checks the result of every method invocation or dereference
then it has to work. There's still the chance of deferred failure from
something that should have been safe, but that might be OK.
-Michael


More information about the Grace-core mailing list