Please vote once and for good: range operations

dsimcha dsimcha at yahoo.com
Wed Jan 28 17:02:59 PST 2009


== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
> It looks like there is endless debate on the naming convention for the
> range operations. Few saw the obvious bugs in the documentation and
> examples :o).
> So please let's vote once and for all. I will note that I disagree we
> should ignore what conventions other languages have. Provincialism is
> the appurtenance of the incult. To that end, I looked around at how some
> languages define some primitives.
> LISP:
> car
> last
>
http://www.gigamonkeys.com/book/they-called-it-lisp-for-a-reason-list-processing.html
> Scheme:
> car
> last
>
http://merd.sourceforge.net/pixel/language-study/syntax-across-languages-per-language/Scheme.html
> ML:
> hd
> last
> http://www.standardml.org/Basis/list.html
> Ocaml:
> hd
> no last
> http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html
> Apparently Ocaml programmers tend to define their own function called
> "last":
>
http://nodens.physics.ox.ac.uk/~mcdonnell/lab/code/code_ocaml/ocaml_fold/ocaml_fold.html
>
http://caml.inria.fr/pub/ml-archives/caml-list/2004/04/06d65a793fa0503218c06783be2facbe.en.html
> Haskell:
> head
> last
> http://www.cs.chalmers.se/Cs/Grundutb/Kurser/d1pt/d1pta/ListDoc/head.html
> http://www.cs.chalmers.se/Cs/Grundutb/Kurser/d1pt/d1pta/ListDoc/last.html
> C++:
> front
> back
> http://support.microsoft.com/kb/158613
> Scala:
> head
> last
> http://www.scala-lang.org/docu/files/api/scala/List.html
> C#:
> Couldn't find after searching MS's asinine dox for 5 mins.
> Java:
> obj.get(0)
> obj.get(obj.size-1)
> http://java.sun.com/j2se/1.4.2/docs/api/java/util/AbstractSequentialList.html
> Python:
> lst[0]
> lst[len(lst)-1]
> So please let's vote once and for all. No choice will please everybody,
> but I want to settle for something that at least won't displease the
> most vehement ones :o).
> Andrei

To me the most important thing is that it's symmetrical, i.e. don't use first, and
then toe or head, and then last.  My vote is for either front/back, first/last or
head/toe (don't care which).  All of the others are pretty bad for the following
reasons:

Lisp, Scheme:  Car has absolutely no intuitive connection with the first part of
anything.  This terminology was probably invented by some 60's programmer who was
seriously stoned.

ML, OCaml, Haskell, Scala:  Not symmetrical.

Python:  At least it looks nice, but anything that looks like array indexing
should be used strictly for random access ranges.

Java:  Worse yet than array indexing, it looks like a lame substitute for an array
index because Java's too stupid to support operator overloading.



More information about the Digitalmars-d mailing list