English version
Accueil     Ŕ propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis ŕ jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml ŕ l'adresse ocaml.org.

Browse thread
Parameter evaluation order
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-08-23 (19:52)
From: Damien Doligez <damien.doligez@i...>
Subject: Re: [Caml-list] Parameter evaluation order
On Aug 23, 2005, at 15:34, Igor Pechtchanski wrote:

> This may be a naďve question, but what's wrong with tuples?  It  
> doesn't
> seem like the order in which the tuple components are evaluated  
> matters
> (in terms of efficiency, that is).  Am I missing something?

Tuples, like currying, is only an encoding.  If you cannot distinguish
between a 4-argument function and a function that takes a 4-tuple as
argument, you have to allocate the tuple in the heap instead of passing
the 4 arguments directly in registers.  Inefficient.

Or you have to make your compiler guess which is which, compile some
functions as taking 4 arguments and some as taking a tuple, and  
between the two representations as needed, in a way that is very similar
to what happens with curried functions, except that this time guessing
"n-ary" every time is not quite as good a heuristic.

Higher-order functions are particularly good at exposing this problem,
because you only know the type of their functional arguments, and you
have to deduce the calling convention from no more information than the
type itself.  But the problem also appears with separate compilation.

-- Damien