<?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/9948de611fa2a519a7c4aa54234716d9"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-01-09T18:28:00"
  subject="Re: [Caml-list] record declaration, SML"
  prev="2003/01/3eeaa34f72ab83397e790fabbb1b7306"
  next="2003/01/0c306debbf9d2c9dfcb5287b6a29bcb2"
  prev-in-thread="2003/01/3eeaa34f72ab83397e790fabbb1b7306"
  next-in-thread="2003/01/78b896e07d18240e06adb3dd5c3c7870"
  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>
Hi,
    You've noticed that OCaml records aren't like SML records. Here are a few 
places where they differ. 

You can't have anonymous records in OCaml, so in the case of a datatype 
declaration like yours you need something like 

type t = C of t_record 
and t_record = { f : int } 

If you hide the record definition, then you can't match on it, but I imagine 
you know that already. 

In the case of anonymous records as function arguments, you could try labels. 

In the case of records in a module sharing field names, well, you can't do 
that either, so you'll need to use classes or find some way to disambiguate 
the fields. This is one of those annoyances of Caml (like the lack of 
overloading :) that you just need to get used to. SML is a bit better here 
IMO, but still not ideal; I think that there was an SML variant (SML#) that 
was appealing but it looks like that idea isn't going anywhere. 

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

Oh yeah, also be careful initializing records with stateful functions, because 
you may be surprised at the order of evaluation. 

-- Brian

On Thu, 9 Jan 2003, A. Ozmen wrote:

&gt; Hi,
&gt; 
&gt; What's best translation of the following SML type?
&gt; datatype t = C of { f : int }
&gt; 
&gt; I have to define extra record types, I guess. Then, not including these
&gt; types in interface (.mli) files? Is this the right approach?
&gt; 
&gt; Thanks.
&gt; __________________________________________________________
&gt; Get your Private, Free Email from HTTP://www.DmailMan.Com
&gt; -------------------
&gt; To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
&gt; Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
&gt; Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
&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>

