Why do some people use keywords for the clauses in the loop macro?

前端 未结 3 1689
执笔经年
执笔经年 2021-01-19 10:18

Does it solve any problem? According to the first footnote of PCL, if not a keyword it interns the symbol in the current package. As all keywords are interned in the keyword

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-19 10:37

    Also from PCL:

    Loop keywords is a bit of a misnomer since they aren't keyword symbols. In fact, LOOP doesn't care what package the symbols are from. When the LOOP macro parses its body, it considers any appropriately named symbols equivalent. You could even use true keywords if you wanted--:for, :across, and so on--because they also have the correct name. But most folks just use plain symbols. Because the loop keywords are used only as syntactic markers, it doesn't matter if they're used for other purposes--as function or variable names.

    (Peter Seibel, Practical Common Lisp, Chapter 7, Footnote 8.)

提交回复
热议问题