Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: [Caml-list] functors with style?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-11-20 (08:27)
From: Shivkumar Chandrasekaran <shiv@e...>
Subject: Re: [Caml-list] functors with style?

On Monday, November 19, 2001, at 10:32 AM, Krishnaswami, Neel wrote:

> A functor is compiled to what is essentially a function that
> takes a record as an argument (the module it receives as an
> argument), and returns a record of functions and values. So
> code generation happens only once for each functor, and each
> functor application takes a very small amount of memory at
> link time.

Which of course is a problem at the "small-scale". For example I would 
like to develop a functor that is generic over the representation of 
reals (float32_elt, float64_elt, fixed_point, etc.). But now if I 
instantiate it for float64_elt and do arithmetic over float64_elt even 
simple operations will be looked-up at run-time leading to a terrible 
performance loss.

Ideally I would prefer it if the compiler allowed the programmer to 
decide which functor applications lead to compile-time code generation 
and which are through dictionary-passing.

For example, in Clean (which has type classes not functors of course), 
instants of basic types be prevented from using dictionary passing. Not 
sure what happens in haskell though...

Bug reports:  FAQ:
To unsubscribe, mail  Archives: