caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Seemingly inconsistent labels for List module
@ 2005-05-29  1:56 Yaron Minsky
  2005-05-30  0:27 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: Yaron Minsky @ 2005-05-29  1:56 UTC (permalink / raw)
  To: Caml Mailing List

I've noticed what appear to be inconsistent labelling on some list
functions, and I'm wondering if I'm properly understanding the reasons
behind the way the labels work.

For example, in the various association list functions, in some cases
the association list is passed with a ~map label, and sometimes with
no label.  Another odd case is the mem and memq functions, both of
which label the list being queried with the label ~set.  In this case,
the labelling mostly seems kind of useless rather than inconsistent.

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

Yaron


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Seemingly inconsistent labels for List module
  2005-05-29  1:56 Seemingly inconsistent labels for List module Yaron Minsky
@ 2005-05-30  0:27 ` Jacques Garrigue
  0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2005-05-30  0:27 UTC (permalink / raw)
  To: yminsky; +Cc: caml-list

From: Yaron Minsky <yminsky@gmail.com>

> I've noticed what appear to be inconsistent labelling on some list
> functions, and I'm wondering if I'm properly understanding the reasons
> behind the way the labels work.
> 
> For example, in the various association list functions, in some cases
> the association list is passed with a ~map label, and sometimes with
> no label.  Another odd case is the mem and memq functions, both of
> which label the list being queried with the label ~set.  In this case,
> 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.

> I'm asking all of this because I'm playing around with writing a
> labelled version of the extlib interface, and I'm wondering whether
> these are mistakes that should be fixed, or whether there are good
> 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-05-30  0:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-29  1:56 Seemingly inconsistent labels for List module Yaron Minsky
2005-05-30  0:27 ` [Caml-list] " Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).