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
[Caml-list] double-functors for types and values
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Naylor <bwv211mail@y...>
Subject: Re: [Caml-list] double-functors for types and values
--- Jacques Garrigue <> wrote:
> There 's something fishy in struct type btype = B.btype end:
> if you're still inside B, you cannot refer to yourself as B.

Whoops, sorry.  You're right - the actual code uses more nested modules or type
renaming, which I left out of the sample code.

> Functors should incur three costs:
> * type abstraction cost: if you depend on abstract types, some data
>   structure accesses cannot be optimized.

I would like to see an example of an unoptimizable case

> * function abstraction cost: all imported functions and (some?)
>   exported functions cannot be called directly. Expensive.

So in the following code:

module MakeA (A : sig type x end) = struct
  let foo = ...
  module MakeB (B : sig val quux : ... end) = struct
    let bar = ...

Both [foo] and [bar] will not cost anything to evoke, but [quux] will cost an
extra indirection since it was imported in the functor parameter?

> * structure access cost: you have to dereference to get to your
>   closures. I believe it's cheap compared to the function abstraction
>   cost. Xavier Leroy had recently some figures showing that a method
>   call (double indirection) was not that much more expensive than an
>   abstract function call.

Is this referring to closures over over local modules (using [let module])
only, or does it have an impact on top-level modules as well?

Can someone come up with a link to the figures mentioned above?


Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: