<?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/10/381db41c1fe9cbbdbe0afbb6f271d21e"
  from="Dan Grossman &lt;djg@c...&gt;"
  author="Dan Grossman"
  date="2003-10-08T17:04:56"
  subject="Re: [Caml-list] Constructors as functions and tuples in constructors"
  prev="2003/10/801b7b1b1823b88569425a89ac8c7458"
  next="2003/10/d04befa7beb24ef22b9d02a9066de8f7"
  prev-in-thread="2003/10/801b7b1b1823b88569425a89ac8c7458"
  next-in-thread="2003/10/7e91616dcacffc47b139c28c440aa9e3"
  prev-thread="2003/10/e79513aa34d4347fb9f61c4d83c4e732"
  next-thread="2003/10/d04befa7beb24ef22b9d02a9066de8f7"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Constructors as functions and tuples in constructors">
<msg 
  url="2003/10/8e30e035c3408ed133428b3777754c4d"
  from="Serge &lt;serge@s...&gt;"
  author="Serge"
  date="2003-10-08T15:57:09"
  subject="[Caml-list] Constructors as functions and tuples in constructors">
<msg 
  url="2003/10/fe9eb2aaab78d81d8a7bbe3b3ba36dc7"
  from="Dan Grossman &lt;djg@c...&gt;"
  author="Dan Grossman"
  date="2003-10-08T16:07:33"
  subject="Re: [Caml-list] Constructors as functions and tuples in constructors">
<msg 
  url="2003/10/801b7b1b1823b88569425a89ac8c7458"
  from="Andreas Rossberg &lt;rossberg@p...&gt;"
  author="Andreas Rossberg"
  date="2003-10-08T16:49:13"
  subject="Re: [Caml-list] Constructors as functions and tuples in constructors">
<msg 
  url="2003/10/381db41c1fe9cbbdbe0afbb6f271d21e"
  from="Dan Grossman &lt;djg@c...&gt;"
  author="Dan Grossman"
  date="2003-10-08T17:04:56"
  subject="Re: [Caml-list] Constructors as functions and tuples in constructors">
<msg 
  url="2003/10/7e91616dcacffc47b139c28c440aa9e3"
  from="Andreas Rossberg &lt;rossberg@p...&gt;"
  author="Andreas Rossberg"
  date="2003-10-09T12:44:06"
  subject="Re: [Caml-list] Constructors as functions and tuples in constructors">
</msg>
</msg>
<msg 
  url="2003/10/7778131e9bb9dc8f0e37e810e13cd361"
  from="Alain.Frisch@e..."
  author="Alain.Frisch@e..."
  date="2003-10-08T18:28:21"
  subject="Re: [Caml-list] Constructors as functions and tuples in constructors">
<msg 
  url="2003/10/bfa15ffef4ce902d4ae1ce0139df5072"
  from="Marcin &apos;Qrczak&apos; Kowalczyk &lt;qrczak@k...&gt;"
  author="Marcin &apos;Qrczak&apos; Kowalczyk"
  date="2003-10-08T18:44:22"
  subject="Re: [Caml-list] Constructors as functions and tuples in constructors">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/10/ee34acd3dffbe03f80f49fb59152a170"
  from="Michal Moskal &lt;malekith@p...&gt;"
  author="Michal Moskal"
  date="2003-10-08T16:15:10"
  subject="Re: [Caml-list] Constructors as functions and tuples in constructors">
</msg>
<msg 
  url="2003/10/897ac973c627b803ed112c8001b114a4"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2003-10-08T16:25:26"
  subject="Re: [Caml-list] Constructors as functions and tuples in constructors">
</msg>
</msg>
</thread>

<contents>

A good point, with these rebuttals:

(1) A pattern-match would have the potential of allocating memory, which 
some may judge poorly.  But the compiler could warn about this.

(2) This transformation does require the type A carries is transparent. 
  So we still couldn't relax the "other" restriction that a signature 
cannot hide an unparenthesized t1 * t2 variant.

(3) It's not clear how far this trivial transformation should be 
generalized.  For example, given
   type t = A of int * int * int * int
which of these should we allow
   A(1,2,3,4)
   A((1,2,3,4))
   A((1,2),(3,4))
   A(1,(2,3),4)
   ...

--Dan

Andreas Rossberg wrote:
&gt; Dan Grossman wrote:
&gt; 
&gt;&gt;
&gt;&gt;&gt; Second, it would also be nice not to have "the concept of constructor
&gt;&gt;&gt; arity", and treat the code below as correct:
&gt;&gt;&gt;
&gt;&gt;&gt; type t = A of int * int
&gt;&gt;&gt; let _ =   match A (17, 0) with
&gt;&gt;&gt;     A z -&gt; match z with (x, y) -&gt; ()
&gt;&gt;
&gt;&gt;
&gt;&gt; Works with type t = A of (int * int).  You put the parens in.  So the 
&gt;&gt; choice is yours.  The advantage of leaving them out is usually 
&gt;&gt; performance.
&gt; 
&gt; 
&gt; That is not true. It would be quite trivial for the compiler to translate
&gt; 
&gt;   A z -&gt; e
&gt; 
&gt; into the equivalent of
&gt; 
&gt;   A(z1,z2) -&gt; let z = (z1,z2) in e
&gt; 
&gt; without affecting performance of other programs in any way. Likewise,
&gt; 
&gt;   A z
&gt; 
&gt; could be transformed into
&gt; 
&gt;   let (z1,z2) = z in A(z1,z2)
&gt; 
&gt; instead of rejecting it. OTOH, your workaround certainly decreases 
&gt; performance for type t, as other pointed out.
&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>

