<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/12/3f6252c496a44de9d62e600f76053aba"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2002-12-10T03:31:02"
  subject="Re: [Caml-list] labels overhead"
  prev="2002/12/b842fa0bde343ece5699d91c444d6e07"
  next="2002/12/13c766eaa064ba0d0d9a119cd8151d2b"
  prev-in-thread="2002/12/b842fa0bde343ece5699d91c444d6e07"
  prev-thread="2002/12/303524700573103127c46d2209d89f49"
  next-thread="2002/12/d1fe91a7143c27a0eff87d4d142f116e"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] labels overhead">
<msg 
  url="2002/12/b842fa0bde343ece5699d91c444d6e07"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-12-10T03:10:15"
  subject="[Caml-list] labels overhead">
<msg 
  url="2002/12/3f6252c496a44de9d62e600f76053aba"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2002-12-10T03:31:02"
  subject="Re: [Caml-list] labels overhead">
</msg>
</msg>
</thread>

<contents>
From: Oleg &lt;oleg_inconnu@myrealbox.com&gt;

&gt; In his book Paradigms of AI Programming, P. Norvig mentions that Lisp 
&gt; functions with keyword arguments [1] suffer a large degree of overhead and 
&gt; that this may also be true for optional and rest arguments, although to a 
&gt; lesser degree [2], depending on the platform [3]. 
&gt; 
&gt; I'm wondering if the same is true for O'Caml. I'm guessing that it's not, 
&gt; since complete function applications using labels can be transformed into 
&gt; "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
Lisp.

---------------------------------------------------------------------------
Jacques Garrigue      Kyoto University     garrigue at kurims.kyoto-u.ac.jp
		&lt;A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/&gt;JG&lt;/A&gt;
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

