More Typing Problems

Florian Weimer fweimer at bfk.de
Tue Sep 7 06:55:11 PDT 2010


* Maurizio Cimadamore:

> with an actual argument of the kind:
>
> #(c){c.getName()}
>
>
> So, given that there's no explicit type on 'c' and given that the method 
> 'select' is accepting *any* subtype of SAM<T,U> for any U, I'm having 
> hard times in imagining an inference scheme that can infer something 
> meaningful (not Object) for 'c'.

This particular case isn't really a problem.  OCaml infers its type as

  < getName : 'a; .. > -> 'a

meaning "a function from an object which has got a getName method (and
possibly other methods) returning a value of type 'a to a value of
type 'a".  There are probably some issues if you treat SAM conversion
as a variant of ML type ascription, but those can probably be solved.

I don't think this would solve the chained calls issue, though,
because select(#(c){c.getName()}) would still not be polymorphic.

-- 
Florian Weimer                <fweimer at bfk.de>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99


More information about the lambda-dev mailing list