<?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="2003/07/b4454db83baee6171cc89bb50c35748f"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-07-28T07:19:00"
  subject="Re: [Caml-list] naming parts of optional arguments?"
  prev="2003/07/813bceb9981111a4ecb3a4e5773de997"
  next="2003/07/61117640c01e53ce9c5abd6333cd32b3"
  prev-in-thread="2003/07/813bceb9981111a4ecb3a4e5773de997"
  next-in-thread="2003/07/749c12c565ddbf0ae14c53f7880c11dc"
  prev-thread="2003/03/386b601bed4a77644727a870ecb9b650"
  next-thread="2003/03/1093f82a8413923ed0b56594e9cc3f1f"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] naming parts of optional arguments?">
<msg 
  url="2003/03/119f206668e58a6a506aaca149c5b9cd"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2003-03-28T01:09:51"
  subject="[Caml-list] naming parts of optional arguments?">
<msg 
  url="2003/03/f3bf978bb3304d9c9091a49a5a30fe8f"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2003-03-28T01:14:42"
  subject="Re: [Caml-list] naming parts of optional arguments?">
<msg 
  url="2003/03/14613e93c23bda4f4329db2dbc87593e"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2003-03-28T02:15:45"
  subject="Re: [Caml-list] naming parts of optional arguments?">
<msg 
  url="2003/07/813bceb9981111a4ecb3a4e5773de997"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2003-07-28T03:43:13"
  subject="Re: [Caml-list] naming parts of optional arguments?">
<msg 
  url="2003/07/b4454db83baee6171cc89bb50c35748f"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-07-28T07:19:00"
  subject="Re: [Caml-list] naming parts of optional arguments?">
<msg 
  url="2003/07/749c12c565ddbf0ae14c53f7880c11dc"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2003-07-28T16:35:21"
  subject="Re: [Caml-list] naming parts of optional arguments?">
<msg 
  url="2003/07/81a0bd462ef07ae6386a9582e266680a"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-07-29T03:20:02"
  subject="Re: [Caml-list] naming parts of optional arguments?">
<msg 
  url="2003/07/3f3ced666b2a7750ac278ca971c5f0bc"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2003-07-29T21:52:34"
  subject="Re: [Caml-list] naming parts of optional arguments?">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/03/1cfe6461b4857eaa0ae5dc27581fe317"
  from="Max Kirillov &lt;max630@m...&gt;"
  author="Max Kirillov"
  date="2003-03-28T01:46:05"
  subject="Re: [Caml-list] naming parts of optional arguments?">
</msg>
</msg>
</thread>

<contents>
From: Chris Hecker &lt;checker@d6.com&gt;
Date: Sun, 27 Jul 2003 20:41:57 -0700

&gt; [old thread resurrected]

Very old indeed.

&gt; Actually, I spoke too soon below, you have to have the "as xy" on there to 
&gt; be able to reference the tuple by xy.  Doesn't that seem redundant given 
&gt; the ?xy: specification (which doesn't seem to be used)?
&gt; 
&gt; # let f ?xy:((x,y)=(0,0)) () = x + y;;
&gt; val f : ?xy:int * int -&gt; unit -&gt; int = &lt;fun&gt;
&gt; # let f ?xy:((x,y)=(0,0)) () = xy;;
&gt; Characters 29-31:
&gt;    let f ?xy:((x,y)=(0,0)) () = xy;;
&gt;                                 ^^
&gt; Unbound value xy
&gt; # let f ?xy:((x,y) as xy =(0,0)) () = xy;;
&gt; val f : ?xy:int * int -&gt; unit -&gt; int * int = &lt;fun&gt;
&gt; # let f ?xy:((x,y) as blah =(0,0)) () = blah;;
&gt; val f : ?xy:int * int -&gt; unit -&gt; int * int = &lt;fun&gt;

No contradiction at all: ?xy: is a label, not a variable name.
If you care about length, you can still write:

  let f ?(xy=(0,0)) () = xy

The distinction between label and variable is useful to avoid masking
the environment.

  let x = ref 3
  let f ?x:(x' = !x + 1) () = x := x'

Jacques Garrigue

-------------------
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>

