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] labels overhead
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] labels overhead
From: Oleg <>

> In his book Paradigms of AI Programming, P. Norvig mentions that Lisp 
> functions with keyword arguments [1] suffer a large degree of overhead and 
> that this may also be true for optional and rest arguments, although to a 
> lesser degree [2], depending on the platform [3]. 
> I'm wondering if the same is true for O'Caml. I'm guessing that it's not, 
> since complete function applications using labels can be transformed into 
> "normal" function calls at compile time. Am I right?

You are right.
There is no overhead for non-optional labels in complete applications.
The overhead for partial applications is basically the same as doing
it by hand, so you cannot say that it is really related to labels.

There is an overhead for optional arguments: they are just encoded as
(Some arg) if present and (None) if absent, and the decoding is dynamic.
This shouldn't be a problem in practive: except when wrapping very
simple arithmetic operations, the overhead is neglectible with respect
to the cost of the function itself.

In both cases, typing allows us to be much more efficient than Common

Jacques Garrigue      Kyoto University     garrigue at
		<A HREF=>JG</A>
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: