<?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="2005/05/4f94c39a6c6a214959cfb92bc5ddaaa3"
  from="Jacques Garrigue &lt;garrigue@m...&gt;"
  author="Jacques Garrigue"
  date="2005-05-30T00:28:52"
  subject="Re: [Caml-list] Seemingly inconsistent labels for List module"
  prev="2005/05/12eb8e9c4d0a3b61eaf2b18ee41fdde4"
  next="2005/05/4829bcb645589c3e49b7525fdbcfb549"
  prev-in-thread="2005/05/73ced3c4131eaf6203b88f228b53e3eb"
  prev-thread="2005/05/e94d144e4737c1c7559bd1fa3df83f34"
  next-thread="2005/05/7bf51516ad250a7e8f6707b4d08b8a2b"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Seemingly inconsistent labels for List module">
<msg 
  url="2005/05/73ced3c4131eaf6203b88f228b53e3eb"
  from="Yaron Minsky &lt;yminsky@g...&gt;"
  author="Yaron Minsky"
  date="2005-05-29T01:56:37"
  subject="Seemingly inconsistent labels for List module">
<msg 
  url="2005/05/4f94c39a6c6a214959cfb92bc5ddaaa3"
  from="Jacques Garrigue &lt;garrigue@m...&gt;"
  author="Jacques Garrigue"
  date="2005-05-30T00:28:52"
  subject="Re: [Caml-list] Seemingly inconsistent labels for List module">
</msg>
</msg>
</thread>

<contents>
From: Yaron Minsky &lt;yminsky@gmail.com&gt;

&gt; I've noticed what appear to be inconsistent labelling on some list
&gt; functions, and I'm wondering if I'm properly understanding the reasons
&gt; behind the way the labels work.
&gt; 
&gt; For example, in the various association list functions, in some cases
&gt; the association list is passed with a ~map label, and sometimes with
&gt; no label.  Another odd case is the mem and memq functions, both of
&gt; which label the list being queried with the label ~set.  In this case,
&gt; the labelling mostly seems kind of useless rather than inconsistent.

There are reasons for both :-)
The ~set label is there, so that you can easily define the membership
function.

   let in_a = List.mem ~set:a

Same thing for ~map in List.mem_assoc.
However, there is no label in List.remove_assoc, because there it
doesn't really make sense: it maps an association list to a new
association list.
There is no label either in List.assoc for a dirty reason:
as the result is a polymorphic variable, if there were a label, one
wouldn't be able to omit it in applications. List.assoc is used very
often.

&gt; I'm asking all of this because I'm playing around with writing a
&gt; labelled version of the extlib interface, and I'm wondering whether
&gt; these are mistakes that should be fixed, or whether there are good
&gt; reasons for them and they should be preserved.

So, there are good reasons, but you may make different choices. The
labelling of the standard library is intentionally light; in other
libraries you might want to put more. Or, conversely, if you choose to
have only a labelled version (avoids maintaining two versions), you
must be careful of using labels only where they will not get in the
way.

      Jacques Garrigue

</contents>

</message>

