[plt-scheme] Re: Re: Typed Scheme
Now that I've thought about this a little more, I am curious as to how
much type information languages like ML have to carry around at runtime.
If you use type-casing in a function can the compiler statically resolve
which case matches at each call site of the function?
Matt
On Sun, 27 May 2007 00:08:31 -0500, I wrote:
> So what are the semantics of case-lambda: when there are multiple cases
> with one argument? It looks like polymorphism is handled using
> runtime checks on union types. This flexible, but since I have to add the
> type annotations anyway, it would be be nice if case-lambda: could handle
> it:
>
> (define-typed-struct leaf ([val : number]))
> (define-typed-struct node ([left : (U node leaf)] [right : (U node leaf)]))
>
> ;;maybe (define: tree-height : ((U node leaf) -> number)
> (define: tree-height : (case-lambda (node -> number) (leaf ->
> number))
> (case-lambda:
> (((t : leaf)) 1)
> (((t : node))
> (max (tree-height (node-left t))
> (tree-height (node-right t))))))
>
--
"You do not really understand something unless you can
explain it to your grandmother." - Albert Einstein.