From: Christian S. <ext...@cs...> - 2006-01-02 22:06:07
|
Hi, Looking at CVS I see in ExtArray.mli: val findi : ('a -> bool) -> 'a array -> int (** [findi p a] returns the index of the first element of array [a] that satisfies the predicate [p]. Raise [Not_found] if there is no value that satisfies [p] in the array [a]. *) and in ExtList.mli: val findi : (int -> 'a -> bool) -> 'a list -> (int * 'a) (** [findi p e l] returns the first element [ai] of [l] along with its index [i] such that [p i ai] is true, or raises [Not_found] if no such element has been found. *) This seems quite inconsistent to me. IMHO, a library should attempt to use equivalent type signatures for functions with the same name. This does not only make functions easier to remember but it also allows easier refactoring of code. For example let i = ExtList.findi p coll in ... should easily be changable to let i = ExtArray.findi p coll in ... in case that coll is a collection that's first implemented as a list and then (while tuning performance) is changed to an array. In the case at hand I would actually advocate to rename ExtList.findi to ExtLib.index_by since there should also be a val index : 'a -> 'a array -> int just as String.index, and index_by would simply be the predicated variant of the standard index function. ExtArray.findi should still be available and should be exchangable with ExtList.findi. What do you think? Friendly, Chris -- Chris Stork <> Support eff.org! <> http://www.ics.uci.edu/~cstork/ OpenPGP fingerprint: B08B 602C C806 C492 D069 021E 41F3 8C8D 50F9 CA2F |