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 8:12

>>6
Not entirely sure what you want to do, but if you just want to iterate over the array using loop, there are better ways to do it. Also, are you sure you want length-map to be a macro? My question to you is how do you want the generated code to look like? Are you sure you want to capture var1 and var2?

The reason your macro fails is because length-map is a macro and you'r trying to calculate (length 'map), not (length map) (compile-time vs run-time). It fails at compile-time when expanding the loop-map macro.

tl;dr: Decide what you need to run at compile-time and what you need to run at runtime. Get an idea of what the expanded code loops like if you want to write a macro which will generate it.

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