Please Help:macro accepting symbols only 
Author Message
 Please Help:macro accepting symbols only

greetings...

i am having a problem.  i am relatively new to lisp..

I am using a macro name make-frame, which takes
a frame name as an argument.

so the command

(make-frame hello)

would make a frame called Hello

But if I store the name of the frame (Hello) in
an intermediate variable called token,
and do this

(make-frame token)

it makes a frame called token. I have tried
many different combinations of quotes, backquote/commas,
etc. in brute force because of my frustration.

here is another failed attempt I had..

Quote:
>(make-frame `(,token))

Error: CREATE-FRAME: arg not a symbol! (LIST TOKEN)

What I want to do is be able use a variable in
place of a symbol to send to the make-frame command.

Any help would REALLY be appreciated

you can email me directly

- neel



Sat, 24 May 1997 11:43:19 GMT  
 Please Help:macro accepting symbols only

   I am using a macro name make-frame, which takes
   a frame name as an argument.

   so the command

   (make-frame hello)

   would make a frame called Hello

   But if I store the name of the frame (Hello) in
   an intermediate variable called token,
   and do this

   (make-frame token)

   it makes a frame called token. I have tried
   many different combinations of quotes, backquote/commas,
   etc. in brute force because of my frustration.

   here is another failed attempt I had..

   >(make-frame `(,token))

   Error: CREATE-FRAME: arg not a symbol! (LIST TOKEN)

   What I want to do is be able use a variable in
   place of a symbol to send to the make-frame command.

   Any help would REALLY be appreciated

   you can email me directly

   - neel

I would suggest that if you want this kind of functionality, `make-frame' should
be a function, not a macro.  Right now, the only advantage you are getting from
`make-frame' being a macro is that macros don't evaluate their arguments, yet
that is exactly the problem you have.

Assume that there's a function make-frame* that takes a symbol as its argument
and makes a frame.  Your examples then become:

(make-frame* 'hello) => #<frame :name HELLO ...>

(make-frame* token)  => #<frame :name HELLO ...>

If it *really* bothers you to have to quote the argument (though I can't see
why, since quote is just a single character and does exactly what you want), you
could then define a macro that uses your function:

(defmacro make-frame (name) `(make-frame* ',name))

(make-frame hello) => #<frame :name HELLO ...>

Notice how all this macro does is quote the argument and punt to the function.
When you want the argument evaluated, you just use the function:

(make-frame* token) => #<frame :name HELLO ...>

Frankly, I think it's better to stick to functions unless you really need the
power of macros.  Here, you don't need the power of macros; you just need the
power of quote.

I hope this helps.

Scott D. Anderson



Mon, 26 May 1997 00:24:00 GMT  
 Please Help:macro accepting symbols only




      I am using a macro name make-frame, which takes
      a frame name as an argument.

      so the command

      (make-frame hello)

      would make a frame called Hello

      But if I store the name of the frame (Hello) in
      an intermediate variable called token,
      and do this

      (make-frame token)

      it makes a frame called token.

   I would suggest that if you want this kind of functionality,
   `make-frame' should be a function, not a macro.

My guess is that Mr. gURu didn't write the make-frame macro.

I will take this opportunity to make the plea that people provide
procedural interfaces to their code as well as macro interfaces so
that people like Mr gURu (I had a simliar problem recently) don't have
to resort to using EVAL, e.g. (eval `(make-frame ,token)).

-Mark
--
Mark Friedman
NASA-Ames Research Center
MS 269-2
Moffett Field, CA 94035-1000

vmail: (415) 604-0573



Tue, 27 May 1997 08:35:48 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. symbol-macros and regular macros

2. help please (DCB Macro)

3. Please Help to use macro

4. Nasm Macros - For / Next Loop, Help Please

5. MASM Macro help, please

6. please, please, please, please, help

7. will someone please, please, please, please HELP me?!!

8. Symbol macros

9. symbol-macro-p?

10. What exactly is a symbol macro?

11. symbol in macro

12. Define-Symbol-Macro

 

 
Powered by phpBB® Forum Software