From: Luke J Crook
Subject: Removing the ' in a macro
Date: 
Message-ID: <h1Zmc.2558$EH6.1982@twister.socal.rr.com>
I have a situation where I need to pass 'rm:RMmatrix3D to a function, 
and then a couple lines down pass (rm:RMmatrix *) to a macro; removing 
the quote.

(defmacro new-pointer (type &optional (value nil))
     (let ((pointer (gensym)))
         `(let ((,pointer (ct:malloc (ct:sizeof ,type))))
             (if ,value
                 (setf (ct:cref (,type *) ,pointer 0) ,value))
             ,pointer)))

Here, ct:sizeof requires 'rm:RMmatrix3D, whereas ct:cref requires 
(rm:RMmatrix3D *)

I can't not quote the value passed to 'type' as new-pointer must also 
handle e.g. :single-float. Which is never quoted.

Any pointers ?

-Luke

From: Barry Margolin
Subject: Re: Removing the ' in a macro
Date: 
Message-ID: <barmar-97775A.00473608052004@comcast.ash.giganews.com>
In article <···················@twister.socal.rr.com>,
 Luke J Crook <······@NO-SPAM.hd-plus.com> wrote:

> I have a situation where I need to pass 'rm:RMmatrix3D to a function, 
> and then a couple lines down pass (rm:RMmatrix *) to a macro; removing 
> the quote.
> 
> (defmacro new-pointer (type &optional (value nil))
>      (let ((pointer (gensym)))
>          `(let ((,pointer (ct:malloc (ct:sizeof ,type))))
>              (if ,value
>                  (setf (ct:cref (,type *) ,pointer 0) ,value))
>              ,pointer)))
> 
> Here, ct:sizeof requires 'rm:RMmatrix3D, whereas ct:cref requires 
> (rm:RMmatrix3D *)
> 
> I can't not quote the value passed to 'type' as new-pointer must also 
> handle e.g. :single-float. Which is never quoted.
> 
> Any pointers ?

(ct:sizeof ',type)

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: Luke J Crook
Subject: Re: Removing the ' in a macro
Date: 
Message-ID: <Xt_mc.2566$EH6.1574@twister.socal.rr.com>
Barry Margolin wrote:

> In article <···················@twister.socal.rr.com>,
>  Luke J Crook <······@NO-SPAM.hd-plus.com> wrote:
> 
> 
>>I have a situation where I need to pass 'rm:RMmatrix3D to a function, 
>>and then a couple lines down pass (rm:RMmatrix *) to a macro; removing 
>>the quote.
> 
> (ct:sizeof ',type)
> 

That's it thanks.
Just pass everything into the macro unquoted and perform the quoting as 
required.

Going back, I see that I can quote e.g. :single-float, :double in 
(ct:sizeof ':double) and it still works as expected. This is actually 
better as (ct:sizeof '((:double 4) 4)) must be quoted to create an array 
of [4][4] floats.

-Luke