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でこれと同じ種類のものを作成するプロセスを私に説明できますか?

4

1 に答える 1

4

この種のマクロは、Scheme では実際にははるかに単純です(標準の Scheme コードでは+define-syntax-ruleが必要です)。基本的に同じことを行いますが、引用/引用解除の混乱を除いてください。define-syntaxsyntax-rules

(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 に移植しました。メーリング リストの投稿を参照してください。

于 2010-01-12T02:53:24.940 に答える