[Grace-core] On Gradual Typing

Michael Homer mwh at ecs.vuw.ac.nz
Wed Jul 17 17:11:35 PDT 2013


On Thu, Jul 18, 2013 at 12:05 PM, James Noble <kjx at ecs.vuw.ac.nz> wrote:
> Hi Michael
>
> a few replies - I'm actually about to go offline for a few days,
> both this & next weekend...
>
>> So far, the conception of how gradual typing works in Grace
>> ...
>> I've mentioned before that I don't think all of this actually fits
>> together, but interest has been low.
>
> It's good to have this email then!
>
>> Let us consider the following completely statically-typed program:
>> 1    object {
>> 2        method x -> Done {
>> 3            self.y
>> 4        }
>> 5    }
>> Line 3 is clearly a static type error because there is no such method
>> "y" on self.
>
> sure.
>
>> Now let us consider the following completely dynamically-typed program:
>> 1    object {
>> 2        method x {
>> 3            self.y
>> 4        }
>> 5    }
>> Line 3 is clearly a static type error because there is no such method
>> "y" on self.
>
> It's not "clearly" a static type error. It's not an error in most dynamically
> typed languages.   We may want to treat it as such, but that's a different
> question.
>
> It's not an error if we can show x is never requested on this object,
> or if only requested from another inheriting / delegating object
> that itself implements y.
It's clearly an error because this is *the same code* as the
statically-typed example. If one of them is an error, so is the other,
and if one of them isn't, neither is the other. The fact that this is
entirely valid dynamically-typed code when you factor in inheritance,
etc, is why there's a problem with that story.
-Michael


More information about the Grace-core mailing list