Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Newbie question Common Lisp generic functions

Name: Anonymous 2011-03-05 6:52

Hi /prog/, this may disappoint you but this is a thread about programming... But it's written by a guy who wants help !
Basically, my question is:
With a generic function and its methods one can check the type/class of the variables that the genfun receives and the genfun therefore chooses the appropiate method, is there any possibility to make it check for the appropiate symbol?

If I can't make it check for the appropiate symbol, am I then forced to simply write one function with many cases?

Name: Anonymous 2011-03-05 7:49

I suspect that the macro loop-map doesn't work because it accidently captures the variable map though I am unsure. I'm going to re-write these macros so they will use  gensym but is there something else I have missed?
The error I get when trying to run the macro loop-map is "map isn't of type sequence".

Source code:



(defmacro length-map (map)
  `(1- (length ,map)))

(defmacro loop-map (map &body body)
  `(loop for var1 from 0 to ,(length-map map) do
        (loop for var2 from 0 to ,(length-map (aref map 0)) do
             ,@body)))


A "map" as I call it looks something like this:

[code]

#( #(a a a)
   #(a a a))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List