You just needed to edit your translation from CL a bit more, there were some extra brackets in your if statements. The following should work:
(defspel game-action [command subj obj place & rest] `(defspel ~command [subject# object#] `(if (and (= *location* '~'~place) (= '~subject# '~'~subj) (= '~object# '~'~obj) (have '~'~subj)) ~@'~rest '(i cant ~'~command like that.)))) (game-action weld chain bucket attic (if (and (have 'bucket) (alter-var-root (var *chain-welded*) (fn [_] true))) '(the chain is now securely welded to the bucket.) '(you do not have a bucket.))) On Thu, Mar 18, 2010 at 4:38 PM, alux <alu...@googlemail.com> wrote: > Again, from my translation of the http://www.lisperati.com/casting.html > tutorial. > > I completely lost track at the macro generating macro (defspel game- > action .. > > In short, Barski writes a very simple (and neat) text adventure. To > avoid wrong assumtions he doesnt talk about macros but SPELs, using > > CL (defmacro defspel (&rest rest) `(defmacro ,@rest)) > Clj (defmacro defspel [& rest] `(defmacro ~...@rest)) > > I translated everything up to the last page > http://www.lisperati.com/actions.html, > then he arrives at > > (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.))))) > > Without CL knowledge, I dont really understand whats going on, but > gave a try (please dont lough to hard :) > > (defspel game-action [command subj obj place & rest] > `(defspel ~command [subject# object#] > `(if ((and (= *location* '~'~place) > (= '~subject# '~'~subj) > (= '~object# '~'~obj) > (have '~'~subj)) > ~@'~rest) > '(i cant ~'~command like that.)))) > > use > > (game-action weld chain bucket attic > (if ((and (have 'bucket) (alter-var-root (var *chain-welded*) (fn > [_] true))) > '(the chain is now securely welded to the bucket.)) > '(you do not have a bucket.))) > > If I try it, I get > > spels=> (weld chain bucket) > java.lang.ClassCastException: java.lang.Boolean cannot be cast to > clojure.lang.I > Fn (NO_SOURCE_FILE:0) > > And I'm stuck. > > My whole try is here: http://paste.lisp.org/+22IH > > Many thanks and a good night. > > alux > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > > To unsubscribe from this group, send email to > clojure+unsubscribegooglegroups.com or reply to this email with the words > "REMOVE ME" as the subject. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.