An alias method for count, as length ?

77 views
Skip to first unread message

Pankaj Doharey

unread,
Sep 14, 2018, 2:30:50 PM9/14/18
to Clojure Dev
Hi All,

Currently in order to find the length of a string or count of a vector we only have one method "count".
(count "string")

Which sometimes does not exactly reflect the context of the code different verbs can mean different contexts. I think adding a small alias should improve 
the readability of the code. For instance :
(length "Helloworld")
=> 10
(count [1 2 3 4 5 6])
=> 6

Would make more sense.

Thanks in advance.

Robert Levy

unread,
Sep 14, 2018, 2:36:23 PM9/14/18
to cloju...@googlegroups.com
That might have made sense to be in clojure.string IMO, but maybe too arbitrary of an addition to be worth it?  It's kind of like how concat in Clojure was called append in Common Lisp.  Neither one is necessarily worse, you just have to remember what it's called in the language you are using.

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.
To post to this group, send email to cloju...@googlegroups.com.
Visit this group at https://groups.google.com/group/clojure-dev.
For more options, visit https://groups.google.com/d/optout.

Pankaj Doharey

unread,
Sep 14, 2018, 3:01:59 PM9/14/18
to Clojure Dev
In my post i outlined that the addition would give us two things, First convenience and second better readability. 
The change required is quite small, and i suppose this has to be done for a host of methods in clojure including 
your aforementioned concat and append. Both are good in different contexts.

Alex Miller

unread,
Sep 14, 2018, 3:14:23 PM9/14/18
to cloju...@googlegroups.com
Thanks for the idea, but we're not interested in adding aliases, either for this or in general.

Alex

Robert Levy

unread,
Sep 14, 2018, 3:14:46 PM9/14/18
to cloju...@googlegroups.com
I don't discount that some might benefit from such aliases, either in a codebase or in a library.  I just don't agree that a proliferation of alias belong in the core of the language.  If anything it might make sense to have an "alternative core", but again that seems like something that should be developed as library.
Reply all
Reply to author
Forward
0 new messages