함수 정의가 make-cd
이고 잘못된 답을 얻기 위해 함수를 실행할 때.(list ...) vs '(...) in Lisp
(defun make-cd (title artist rating ripped)
'(:title title :artist artist :rating rating :ripped ripped))
(add-record (make-cd "Roses" "Kathy Mattea" 7 t))
(:TITLE TITLE :ARTIST ARTIST :RATING RATING :RIPPED RIPPED)
나는 정답을 얻을 수 (list ...)
을 사용해야합니다.
(defun make-cd (title artist rating ripped)
(list :title title :artist artist :rating rating :ripped ripped))
(add-record (make-cd "Roses" "Kathy Mattea" 7 t))
(:TITLE "Roses" :ARTIST "Kathy Mattea" :RATING 7 :RIPPED T)
왜 그렇습니까?
'(X Y Z)'는'(QUOTE (X Y Z))'의 줄임말입니다. ['QUOTE'] (http : //www.lispworks.com/documentation/HyperSpec/Body/s_quote.htm)은 단순히 주어진 객체를 평가하는 대신 리터럴 데이터로 반환합니다. 즉, 여러분의 예'TITLE'에서'ARTIST','RATING'과'RIPPED'는 그 이름을 가진 변수에 대한 참조가 아닙니다; 그들은 단지 문자 그대로의 상징입니다. – jkiiski
이것은 '$ WYSIWYG'가 $ WYSIWYG '이고 $ WYSIWYG가 아닌 문자열을 보간하지 않는 상수 문자열의 차이와 비슷합니다. "// =>" "This is is 대체되지 "않습니다. – Sylwester