[Grace-core] talking generics with Gilad over lunch

James Noble kjx at ecs.vuw.ac.nz
Tue Nov 5 15:04:28 PST 2013


>  agree with Andrew.  There are intriguing ideas here, but those can be handled in some extension that is out of scope for now.  I do think that are dialects will need to be able to have the capacity of changing the ASTs eventually

that way lies Racket....

> (and this could support your type-like predicates), but it's not a high priority.

agree it's not a high priority --- not sure why we need to change ASTs to get that.

> I'd say that for now we're best off having types look like types.  Other notations tend to obscure the code.  We need to keep Grace looking simple.  ... and different pluggable static type checkers can handle whatever type inference is desired for types left out (and that is likely a place where we'd like the checker to change the AST).  Right now, I'd be tempted to just handle if-then-else expressions as a special case for my simple type-checker and require everything else to include type annotations.  You of course could write a static type checker with different characteristics.  Let a thousand flowers (or type-checkers) bloom.

after talking with Michael (and thinking about Dart) - if/then/else isn't too bad, because a checker already has the "mandate" to handle it specially or to flow types locally. 

the only issue is the static checker influencing *dynamic* typing later on. 
note that even if you did something like

> List.new<  (if (numbersVsstrings) then {Number} else {String})  >  

(still using the <> syntax), or 

> List.new type (if (numbersVsstrings) then {Number} else {String}) 

using the generalised request syntax  then you are explicitly binding the types.

the real issue is more with code like

def mySeqOfStrings : Sequence.type(String)  = [ "a", "b", "c" ]

mySeqOfStrings.map { x: String -> x + 3 }       

vs 

mySeqOfStrings.map { x -> x + 3 }        // Dynamic

a static type checker can infer the type of the "x" argument to the lambda.
but that can't feed into the dynamic type

so you'll get an error at the "+", not at the "block called with wrong type" 


J 


More information about the Grace-core mailing list