为什么Clojure之父说Scheme的true/false被打破了?

发布于 2024-11-03 21:33:00 字数 479 浏览 1 评论 0原文

在此视频中,Rich Hickey 向 Lisp 程序员介绍了 Clojure。

时间 01:10:42,他在 Clojure/Common Lisp/Scheme/Java 中谈到了 nil/false/end-of-sequence/'()。他说:“计有真有假,但都破了。”

幻灯片

我不明白他为什么这么说,为什么他认为它“坏了”?

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"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

成熟的代价 2024-11-10 21:33:00

我觉得你宁愿从马嘴里看到它,所以这里有一个选择摘录自 a消息丰富的帖子:

方案#t 几乎完成
无意义,作为计划条件
测试#f/非#f,而不是#f/#t。我不
认为 #f 值有很大用处
无论如何,并基于条件
这意味着写很多(如果(不是
(null? x))... 其中 (如果 x... 就可以
在 Clojure/CL 中,以及大量的
表达能力下降时
处理序列、过滤器等。

该消息中的链接也很有价值,尽管第二个可能有点诗意。

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.

我喜欢麦丽素 2024-11-10 21:33:00

从您发布的图表中,我认为这是因为与图表中的所有其他语言不同,Scheme 使用 nilfalse 以外的内容作为 end-of-seq。由于 '()非#f,因此它在条件中将是真值,但在序列结束检查中充当假值。

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.

逐鹿 2024-11-10 21:33:00

在Scheme中,任何值(除了#f,它是False)都可以在条件测试中用作True。更多信息此处

更新
忘记这个答案吧,因为这对于 Clojure 当然是一样的。我不喜欢所有非假值的隐式真理,例如在 (println (if 1 "true" "false")) 中。就我个人而言,我认为这已经被打破了,但里奇可能正在考虑别的事情。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文