39

In this video, Rich Hickey introduced Clojure for Lisp programmers.

At time 01:10:42, he talked about nil/false/end-of-sequence/'() among Clojure/Common Lisp/Scheme/Java. He said: "Scheme has true and false, but they are broken."

slide

I don't understand why he said that and why does he consider it's "broken"?

Max
  • 1,741
  • 3
  • 23
  • 40
yehnan
  • 5,392
  • 6
  • 32
  • 38

3 Answers3

47

It strikes me you'd rather see it from the horse's mouth, so here's a choice extract from a message Rich posted:

Scheme #t is almost completely meaningless, as Scheme conditionals test for #f/non-#f, not #f/#t. I don't think the value #f has much utility whatsoever, and basing conditionals on it means writing a lot of (if (not (null? x))... where (if x... will do in Clojure/CL, and a substantial reduction in expressive power when dealing with sequences, filters etc.

The links in that message are also worthwhile, though the second one may be a bit poetic.

Arthur Shipkowski
  • 3,606
  • 1
  • 22
  • 30
  • 2
    Honestly, I am still having question marks in my head. So only give you half the points. Excuse me. – yehnan May 10 '11 at 14:07
  • 2
    so if I understand you correctly, Rich is really complaining that, in Scheme, nil evaluates to true (instead of false) in conditionals? That does seem like a poor design to me. – Nathan Davis May 21 '11 at 02:26
  • 2
    @Nathan - Indeed, it evaluates to #t. Technically, '() evaluates to #t, as Scheme lacks nil unless you define it. – Arthur Shipkowski May 26 '11 at 21:30
9

From the chart you posted I'd assume it's because Scheme unlike all the other languages in the chart uses something other than nil or false for end-of-seq. Since '() is non-#f it would be a truthy value in a conditional, but acts as a falsy value for end of sequence checks.

Michael Kohl
  • 66,324
  • 14
  • 138
  • 158
  • Well, I agree with you. But your point doesn't satisfy my need yet. Why called it broken? – yehnan Apr 29 '11 at 14:27
  • 6
    I guess some people would consider it broken if the same thing can be either truthy or falsy depening on context. – Michael Kohl Apr 29 '11 at 16:03
  • In my opinion end-of-list and false are two distinct concepts and scheme gets it right by distinguishing those. He should have included javascript in that chart, compared to its 7 false values clojure nearly looks sane. – Jörn Horstmann Apr 30 '11 at 17:42
  • 1
    `clojure=> (if '() 1 2)` returns 1, so `'()` being a #t-value cannot be the reason for calling it broken. (unless rich considers clojures boolean values to be broken as well) – subsub May 09 '11 at 21:12
  • @subsub: That's exactly what my last sentence means. Some people could consider it broken that Scheme uses a value that's usually truthy to represent end-of-seq. Clojure doesn't, since `()` (no need to quote in Clojure) is truthy and therefore also not used to represent the end of a sequence. Some people like Jörn disagree and I can see why. – Michael Kohl May 09 '11 at 22:07
  • @Michael-kohl: Ah, I thought you were referring to scheme in that last sentence. – subsub May 10 '11 at 06:24
3

In Scheme any value (apart from #f which is False) can be used as True in a conditional test. More info here.

Update Forget this answer, since it's the same for Clojure of course. I don't like this implicit truth for all values that are not false, for example in (println (if 1 "true" "false")). Personally I would consider that broken but Rich is probably thinking of something else.

Maurits Rijk
  • 9,789
  • 2
  • 36
  • 53