<?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/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"
  prev="2003/10/ee34acd3dffbe03f80f49fb59152a170"
  next="2003/10/801b7b1b1823b88569425a89ac8c7458"
  prev-in-thread="2003/10/ee34acd3dffbe03f80f49fb59152a170"
  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>
&gt; Gentlemen!
&gt;
&gt; There are two features, which might it be useful to support in the
&gt; language w/out modifying it much. And they both are about greater
&gt; generality of the language.
&gt;
&gt; First, it would be nice to have constructors as functions like below:
&gt;
&gt; List. map Some [17]

This is only syntaxic sugar. First class constructors are easy to add to the
language, that's just a matter of will from the INRIA team to choose to add
it or not ( meaning : since they didn't put the feature in the language yet,
they might have good reasons to do so. ).

&gt; Second, it would also be nice not to have "the concept of constructor
&gt; arity", and treat the code below as correct:
&gt;
&gt; type t = A of int * int
&gt; let _ =
&gt;   match A (17, 0) with
&gt;     A z -&gt; match z with (x, y) -&gt; ()
&gt;
&gt; Does anybody know, whether this is possible? Or, if not, what are the
&gt; prohibiting reasons?

This is possible :
type t = A of (int * int)

Notice the difference :
- in the first case, you alloc a block with tag "A" of size 2
- in the second, you alloc a block with tag "A" of size 1 containing a tuple
(a block of size 2 with tag 0 containing the two ints). There is then one
more indirection in your integers access but the tuple can be returned
directly without any added allocation.

Nicolas Cannasse

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

