在https://www.thc.org/root/phun/unmaintain.html中, Lisp被认为是这样,"LISP is a dream language for the writer of unmaintainable code."然后继续提供一些代码示例.在最近的黑客新闻评论中,这些被认为是" 任何知道口齿不清的人在一秒钟之内就可以阅读和理解的东西 ".
My question is, as someone with only a very small bit of experience in Clojure — what do they mean?
(lambda (*<8-]= *<8-[= ) (or *<8-]= *<8-[= ))
I imagine that some of this syntax means something like the #(blah %) syntax from clojure, right?
(defun :-] (<) (= < 2))
Mostly lost here. Defining a function called :-] that takes an argument < and checks if it's = to 2? Perhaps (<) is a partial function regarding less than?
Their point is just that the range of available identifiers is larger, but the semantic overloading of certain characters makes it easy to write code that looks like it might be doing something weird.
If you take a closer look at the first sample,
(lambda (*<8-]= *<8-[= ) (or *<8-]= *<8-[= ))
Run Code Online (Sandbox Code Playgroud)
and rename the variable *<8-]= to a, and *<8-[= to b, we see that it's a pretty simple function:
(lambda (a b) (or a b))
Run Code Online (Sandbox Code Playgroud)
In the second case, it's just making the point that since things like +, <, and so on aren't special operators or anything, they're just symbols with the names "+" and "<", you can use them as variable names. Again, we can rename variables and turn
(defun :-] (<) (= < 2))
Run Code Online (Sandbox Code Playgroud)
into
(defun :-] (a) (= a 2))
Run Code Online (Sandbox Code Playgroud)
This one is rather unusual, since the colon prefix indicates a keyword (a special sort of self-evaluating constant in Common Lisp), but SBCL seems to handle it:
CL-USER> (defun :-] (<) (= < 2))
:-]
CL-USER> (:-] 2)
T
CL-USER> (:-] 3)
NIL
Run Code Online (Sandbox Code Playgroud)
Putting function definitions on keyword symbols is somewhat unusual, but it's not unheard of, and can be useful. E.g., see Naming functions with keywords.
| 归档时间: |
|
| 查看次数: |
370 次 |
| 最近记录: |