Re: Stdlib regularity

From: skaller (skaller@maxtal.com.au)
Date: Thu Oct 07 1999 - 09:33:25 MET DST


Date: Thu, 07 Oct 1999 17:33:25 +1000
From: skaller <skaller@maxtal.com.au>
To: Ohad Rodeh <orodeh@cs.cornell.edu>
Subject: Re: Stdlib regularity

Ohad Rodeh wrote:
>
> Caml list,
> I have used OCaml extensively in the past few years, and I've had
> some misgivings about the CAML standard library argument ordering.
> What do you think?

While I tend to agree with the sentiment (and, apart from just
remembering
the ordering, the most likely Currying isn't possible when the data
structure
type isn't the first argument), it would create a compatibility
problem to just change the existing library, and a mess to add a new set
of modules just to 'fix' the argument order to be slightly more
intuitive.
I guess the original reasoning was more to do with reading order:

        List.mem element theList

reads well as

        element <is member of> theList

This kind of issue (argument order) was much more important in C++,
where generics represented by templates _mandate_ consistency
(in the naming conventions as well). Even before the STL was finalised,
it was being used enough that people argued against changing it
to avoid breaking code.

It is probably more important to consider how to introduce
FISh 2 style polymorphism, in which functions like 'map'
and 'iter' can be applied to _any_ data structure.
In that case, you gain consistency automatically, since there
is _really_ only one such algorithm for all data structures :-)

A more limited way to achieve this is to use an STL style
library; that is, iterator based algorithms, with the client
supplying the iterators.

-- 
John Skaller, mailto:skaller@maxtal.com.au
1/10 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
downloads: http://www.triode.net.au/~skaller



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:26 MET