[Grace-core] Should Grace abandon "gradual typing" for "like typing"?
James Noble
kjx at ecs.vuw.ac.nz
Thu Jul 28 13:40:32 PDT 2016
On 29/07/2016, at 8:21AM, Vitek, Jan <j.vitek at northeastern.edu> wrote:
>
> Like types will never cause runtime failures, while concrete types may.
OK, so now I'm concerned that I'm missing something.
if I've got a like type such as
type Fooable = like { foo } // something Fooable has a Foo method
what happens if I assign an object that doesn't have a Foo method to that variable (and, say, never actually call the foo method). Presumably that object is flowing in e.g. from a variable or parameter of type Unknown (aka Dynamic)
so we don''t know at compile-time (or type-check type) whether or not
the object is Fooable...
method assignToFooable( other : Unknown -> like Fooable {
// now I'm being extra explicit other is dynamically typed
def x : like Fooable = other
return x
}
Does the assignment to a Fooable cause an error or not? (I guess I should read the formalsims, but...)
I thought Dart in checked mode *would* raise a dynamic error there.
I thought Thorn would too, and if we can be sure that other does
not have a foo method we get an eager error...?
James
More information about the Grace-core
mailing list