2010-01-11 3 views
2
(defspel game-action (command subj obj place &rest rest) 
    `(defspel ,command (subject object) 
    `(cond ((and (eq *location* ',',place) 
        (eq ',subject ',',subj) 
        (eq ',object ',',obj) 
        (have ',',subj)) 
      ,@',rest) 
      (t '(i cant ,',command like that.))))) 

'매크로 정의 매크로'의 코드는 http://www.lisperati.com/actions.html입니다. 나는 그것을 체계로 적절하게 변환하는 것처럼 보이지 않는다. 누군가 제가 Scheme에서 이와 동일한 종류의 것을 만드는 과정을 나에게 설명 할 수 있습니까?PLT 스키마 : 'LISP에서 SPEL 캐스팅'의 매크로 중 하나 변환

답변

4

이 매크로는 define-syntax-rule (표준 체계 코드에서 define-syntax + syntax-rules)으로 모두 수행 할 수 있으므로 실제로 Scheme에서 훨씬 간단합니다. 당신은 기본적으로 동일한 인용문을 제외하고 전체 인용문/인용 부호를 뒤집어 쓰지 않습니다. 메일 링리스트에 post를 참조 -

(defspel (game-action command subj obj place rest ...) 
    (defspel (command subject object) 
    (cond [(and (eq? *location* 'place) 
       (eq? 'subject 'subj) 
       (eq? 'object 'obj) 
       (have 'subj)) 
      rest ...] 
      [else '(i cant command like that.)]))) 

그리고 이것은 대부분의 코드 실제로 이후

, 나는 PLT에 전체를 이식.

+0

대단히 감사합니다!^_ ^ –