Torben Ęgidius Mogensen wrote:
> Most functional language compilers don't do this kind of multiple
> instantiation but instead exploit that polymorphic functions don't
> need to access the polymorphic data so, as long as the size of the
> polymorphic data is the same, the same code can work on any type.
> Hence, the compilers ensure that all data has the same size (typically
> one machine word), storing larger data in the heap and just keep a
> pointer to it in a register or stack slot. Hence, you need only one
> copy of each polymorphic function and you can compile this in advance
> without knowing which future instances it will be applied to. The
> disadvantage is that you need to store more things in the heap.
Certainly in the 1990s compilers like OCaml did that but modern FPL
compilers often target CLRs like .NET and inherit this functionality from
them.
--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u


|