Please vote once and for good: range operations
John Reimer
terminal.node at gmail.com
Wed Jan 28 20:13:44 PST 2009
Hello Andrei,
> 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-languag
> es-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_fo
> ld/ocaml_fold.html
> http://caml.inria.fr/pub/ml-archives/caml-list/2004/04/06d65a793fa0503
> 218c06783be2facbe.en.html
> Haskell:
> head
> last
> http://www.cs.chalmers.se/Cs/Grundutb/Kurser/d1pt/d1pta/ListDoc/head.h
> tml
> http://www.cs.chalmers.se/Cs/Grundutb/Kurser/d1pt/d1pta/ListDoc/last.h
> tml
> 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/AbstractSequentialLi
> st.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
>
head/last. I consider it symmetrical in the context of use, because in this
case head implies "first", not a part of our anatomy.
Another option:
head/stern... but, arguably, this is not perfectly symmetrical.
Otherwise, I just go with whatever gets put in there, I guess. :)
-JJR
More information about the Digitalmars-d
mailing list