On 13/10/2014, at 3:53 AM, Shayne Fletcher wrote:

> 
> On Sun, Oct 12, 2014 at 1:04 AM, john skaller <skal...@users.sourceforge.net> 
> wrote:
> For example
> 
>         reduce[T] double_rev(x:list[T]) : rev (rev x) => x;
> 
> will not work if list[T] with T->int changes the type to list_of_int
> and the rev functions to rev_of_int
> 
> ​Sorry, maybe not quite getting it. Surely,  T <- int, rev_{1} = rev_{2} <- 
> rev_list_of_int. What's the problem?​ Is it that the polymorphism of of the 
> reduction rule has been lost?

When rev[T] of list[T] is monomorphised its "name" is changed to a new function

        rev_of_int[] of list_of_int[]

Actually it's integer index in the symbol table is changed.

More precisely, a brand new function is created which reverses
only integer list.

So the pattern matching to find things to reduce is looking for
the old "rev" function index.; It won't see the new rev_of_int index.

To fully see, if you had a reverse of a list of strings, you would get

        rev_of_string[] of (list_of_string[])

etc etc. Another way to look at this is that polymorphic code like
C++ templates is reduced to monomorphic code like C functions:
one function for each specialisation.

This problem *already* existed if a function is inlined, then if its
child function is made a child of the new parent that requires
that child to be specialised. I did wonder why some reductions
didn't work. 

Note that the instantiator doesn't specialised functions like this.
It just makes a table mapping

        index,type list -> new index

which is only used at C++ code generation time. Early monomorphisation
would more or less eliminate the need for that table, and remove the need
to do any type specialisations, indeed, remove the need to think much
about types at all. Speed up the compiler.


--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://p.sf.net/sfu/Zoho
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to