On May 26, 2013, at 5:47 AM, "Alex L." <alexander.lo...@gmail.com> wrote:
> First, the use of seq as a
> terminating condition is the idiomatic way to test whether a sequence is 
> empty. 

In natural languages, idioms change. Sometimes it's to the despair of purists: 
for example, I've had to accept that "hopefully" at the beginning of a sentence 
doesn't act as an adverb:

    Hopefully, he will ascend to a higher plane.
    Having consumed the HOPE1 drug, he will hopefully ascend to a higher plane.

The same is true of programming languages. When I was programming on the 
PDP-11, it was idiomatic to use pre-increment instead of post-increment when 
either would do:

    for (i=0; i<N; ++i) …      /* right */
    for (i=0; i<N; i++) …      /* wrong */

That was because the former compiled into one machine language instruction, but 
the latter required two. PDP-11s were slow, so it could matter.

There exists in 2013 a person who, in a code review, insists that every 
post-increment be changed to a pre-increment, even though (1) compilers are way 
smarter than they were in 1981, (2) computers are way faster too, and (3) 
insisting on a stylistic point only relevant in the distant past is the sign of 
a mind past its sell-by date. I've met that person.

There is no one who understands `(if (seq thing)` who wouldn't understand 
`(if (not (empty? thing))` or, better, `(if (not-empty? thing)`. The converse 
is not true. That suggests that the latter should be the idiom, given that the 
difference between them is as consequential as the difference between `++i` and 
`i++`. 

It's fun to make use of esoterica like `seq`'s behavior with an empty list. 
Back in the early days, it was necessary. Witness Guy Steele's StrangeLoop talk 
that began with the need to get a program to fit onto a single punched card. 
And language implementors still need to care about those things. 

But, for the rest of us, the necessity has drained out of that kind of 
esoterica. It's now more of a shibboleth, a way to identify yourself as one of 
the tribe. That's actually tolerable human behavior, but those who indulge in 
it shouldn't feel *smug*. Rather, the opposite.

--------
Latest book: /Functional Programming for the Object-Oriented Programmer/
https://leanpub.com/fp-oo

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to