On Mon, 2006-09-11 at 23:35 -0400, Peter Tanski wrote:
[]

Just to be sure we understand: Felix doesn't 'instantiate'
polymorphic functions during lookup.

If it did, we'd have ground types flowing through call chains,
and be passing a concrete typeclass instance through as well.

>From your comments (Peter) you seem to be expecting this,
but that's NOT how it works. C++ may do that, Felix doesn't.

When there are polymorphic functions:

        fun f[t] ...
        fun g[u] (x:u) => f[u] x
        .. g[int] 1 ...

Then we do lookup in g for the call f[u] x.
The fact that the call g[int] will later make
u, and then t, 'int' is irrelevant: the call to
f is encoded, effectively as

        f with t->u

in the body of g. The call of g is

        g with u->int

The instantiator code generator actually composes 
the substitutions to obtain

        f with t -> u -> int
        
The instantiator does this to make a list of all the
instances of f, in this case just f with t-> int.

And the code generator, to replace 't' with 'int' which
in turn is replaced by the C++ name for int (also happens
to be int).

The point is, the binding of f[u] x in the body of g
is entirely independent of the fact that g[int] 1
is evaluated. The front end works like ML: all the 
bindings are fully polymorphic.


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to