문제

I begin to learn newlisp, but the quote and ' puzzle me.

> (= '(quote 1) ''1)  
nil

or

> (first (quote (quote 1)))  
quote

> (first ''1)  
ERR: array, list or string expected in function first : ''1

in newlisp, quote is different from ' ?
or, this is a bug?

도움이 되었습니까?

해결책

There is a subtle difference between the two. The single quote is resolved during source code translation, when the quoted cell is wrapped into a protecting envelope. The function quote does the same but during evaluation. For most purposes they behave in the same way.

So the function quote is more like the original Lisp quote. The ' is an optimization performed during code translation. If you want to know more about code translation and evaluation, compare the functions read-expr and eval-string.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top