if/when-let(*) 和 and-let* 的演变历史(也就是 foo-let(*))

没仔细读过if-let(*) 的文档。一直以为它们真的就是和 let(*) 一样,一个支持顺序绑定,一个只支持并行绑定的。(所以我用的时候也是一直按照这个语义来在不同的场景使用 when-let 和 when-let* 的)

直到这个帖子才知道原来 if-let(*) 的区别只有一个绑定的时候可以省略一对括号而已。

只能说 let 表示并行绑定而 let* 表示顺序绑定太过深入人心,看到形似的就会这样想…

写了个总结,整理了一下。

2 个赞

总结一下几个问题:

  • 定义移进 subr.el 时没有严格的审核机制看是否设计合理
  • 进了 subr.el 以后还能随意改行为,在这个阶段即使是 bug 也该认成 feature 了吧,这里的问题不是要不要 obsolete (当然进 subr 才没几年就 obsolete 也是伤信任),而是能不能改同名定义的行为,这个可不能乱开先例
  • 已经有 mepla 开发者意识到自已没被 emacs-devel 当人看

以及

  • 瞎引入 Clojure feature 终于吃到苦果了
  • 不用抽象是最好的
  • 没有 let 版本却有 let* 也过于抽象了

亲身体会过几次

4 个赞

非常好总结,我改一下解决方案

bug#73853: 31.0.50; and-let* is useless

还在吵还在吵 :rofl:

1 个赞

tarsius/cond-let: Binding conditionals

magit 作者整的新活 :laughing:

This package implements the missing and-let and while-let*, and the original cond-let, cond-let*, and$ and and>.

This package additionally provides more consistent and improved implementations of the binding conditionals already provided by Emacs. Merely loading this library does not shawow the built-in implementations; this can optionally be done in the context of an individual library, as described below.

cond-let and cond-let* are provided exactly under these names. The names of all other macros implemented by this package begin with cond-let--, the package’s prefix for private symbol.

Users of this package are not expected to use these unwieldy names. Instead one should use Emacs’ shorthand feature to use all or some of these macros by their conceptual names.

;; Users of this package are not expected to use these unwieldy
;; names.  Instead one should use Emacs' shorthand feature to use
;; all or some of these macros by their conceptual names.  E.g., if
;; you want to use all of the available macros, add this at the end
;; of a library.

;; Local Variables:
;; read-symbol-shorthands: (
;;   ("and$"      . "cond-let--and$")
;;   ("and>"      . "cond-let--and>")
;;   ("and-let"   . "cond-let--and-let")
;;   ("if-let"    . "cond-let--if-let")
;;   ("when-let"  . "cond-let--when-let")
;;   ("while-let" . "cond-let--while-let"))
;; End:
1 个赞

大概率不是新活,感觉大概率是 magit 以后要引用的新 lib 了。之前他搞了一个 lib 名字叫 llama,其实也是一个匿名函数的语法糖,但是名字和 meta 出的 llama AI 模型名字太像了,太容易引起困惑了。

2 个赞

and-let* 作为 and 的扩展挺直观的,不知道怎么就 useless 了。这样动不动就 obsolete 某些东西,只会让人畏惧得 不得不建立自己的抽象。and-let* 当初怎么进 core 的呢,obsolete 前把当初进 core 的理由也拉出来看看会不会更好呢?

1 个赞

现在 magit 已经依赖这个 cond-let 了 :grinning_face_with_smiling_eyes:

1 个赞