<?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/01/78b896e07d18240e06adb3dd5c3c7870"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2003-01-10T09:21:17"
  subject="Re: [Caml-list] record declaration, SML"
  prev="2003/01/e1fc2cb6dafc061afc5f6f4faf822561"
  next="2003/01/f9c3d99bba40e8cf1b94eb7cb5777c81"
  prev-in-thread="2003/01/9948de611fa2a519a7c4aa54234716d9"
  next-in-thread="2003/01/93b1291528684957aead21b72f0a9544"
  prev-thread="2003/01/37bde005f875aa75e55ca6ee21ec7ede"
  next-thread="2003/01/277d23fbd8d964d99d8b80b7f032590a"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] record declaration, SML">
<msg 
  url="2003/01/3eeaa34f72ab83397e790fabbb1b7306"
  from="A. Ozmen &lt;aoz@d...&gt;"
  author="A. Ozmen"
  date="2003-01-09T18:04:44"
  subject="[Caml-list] record declaration, SML">
<msg 
  url="2003/01/9948de611fa2a519a7c4aa54234716d9"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-01-09T18:28:00"
  subject="Re: [Caml-list] record declaration, SML">
<msg 
  url="2003/01/78b896e07d18240e06adb3dd5c3c7870"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2003-01-10T09:21:17"
  subject="Re: [Caml-list] record declaration, SML">
<msg 
  url="2003/01/93b1291528684957aead21b72f0a9544"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-01-10T14:34:43"
  subject="Re: [Caml-list] record declaration, SML">
</msg>
</msg>
<msg 
  url="2003/01/f9c3d99bba40e8cf1b94eb7cb5777c81"
  from="A. Ozmen &lt;aoz@d...&gt;"
  author="A. Ozmen"
  date="2003-01-10T09:36:18"
  subject="Re: [Caml-list] record declaration, SML">
</msg>
</msg>
<msg 
  url="2003/01/1ca66d24a440edbd8e33b050a8ffc794"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2003-01-09T22:42:08"
  subject="Re: [Caml-list] record declaration, SML">
<msg 
  url="2003/01/d88536eb5cd8c413b396f1cff8f000e6"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2003-01-09T23:11:48"
  subject="Re: [Caml-list] record declaration, SML">
<msg 
  url="2003/01/5139d8a47eedbc92eee9fe549d84283c"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2003-01-10T02:59:41"
  subject="Re: [Caml-list] record declaration, SML">
</msg>
<msg 
  url="2003/01/be4cf6635106b2ef386963204ac08a99"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-01-10T03:45:45"
  subject="Re: [Caml-list] record declaration, SML">
<msg 
  url="2003/01/e1fc2cb6dafc061afc5f6f4faf822561"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2003-01-10T07:43:33"
  subject="Re: [Caml-list] record declaration, SML">
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
&gt; &gt; What's best translation of the following SML type?
&gt; &gt; datatype t = C of { f : int }
&gt; In the case of records in a module sharing field names, well, you can't do 
&gt; that either, so you'll need to use classes or find some way to disambiguate 
&gt; the fields.

Sometimes, it's acceptable to just omit the record type:

        type t = C of int

You lose the naming of the arguments of the constructor, but for small
numbers of arguments (e.g. 1 or 2), this is often tolerable.

&gt; There are a few other conveniences in SML record handling too, like the ... 
&gt; notation, that don't exist in OCaml. 

You mean, in pattern-matching over records?  Caml offers the same
functionality without the ... notation, e.g.

        type r = { x: int; y: int }

        match r with { x = 1 } -&gt; ...

Because records are declared in advance, there is no requirement that
all record labels be mentioned in a pattern matching.

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

