I have a macro which defines constants as powers of two (for
interfacing with xlib):
(defmacro define-bitmask-constants (&rest name-power-pairs)
"Define a list of constants from name-value pairs, raising 2 to
the power value."
(labels ((dbc (pairs)
(case (length pairs)
(0 nil)
(1 (error "no power after ~a" (car name-power-pairs)))
(t (destructuring-bind (name power &rest rest) pairs
`((defconstant ,name (expt 2 ,power))
,@(dbc rest)))))))
`(progn
,@(dbc name-power-pairs))))
But when I apply it, the first argument is indented too much. For
example,
(define-bitmask-constants
USPosition 0
USSize 1
PPosition 2
PSize 3
PMinSize 4
PMaxSize 5
PResizeInc 6
PAspect 7
PBaseSize 8
PWinGravity 9)
Any suggestions? This is cosmetic, but I would be interested to know
why this occurs.
Thanks,
Tamas
On Thu, 02 Aug 2007 16:03:10 +0200, <······@gmail.com> wrote:
> I have a macro which defines constants as powers of two (for
> interfacing with xlib):
>...
> `((defconstant ,name (expt 2 ,power))
>
> (define-bitmask-constants
> USPosition 0
> USSize 1
> PPosition 2
> PSize 3
> PMinSize 4
> PMaxSize 5
> PResizeInc 6
> PAspect 7
> PBaseSize 8
> PWinGravity 9)
Ah, where are the powers of 2 again?
--
Lisp: Powering `Impossible Thoughts since 1958
--
Posted via a free Usenet account from http://www.teranews.com
On Thu, 2 Aug 2007 07:33:00 -0700, <········@CloudDancer.com> wrote:
> On Thu, 02 Aug 2007 16:03:10 +0200, <······@gmail.com> wrote:
>> I have a macro which defines constants as powers of two (for
>> interfacing with xlib):
>>...
>> `((defconstant ,name (expt 2 ,power))
>>
>> (define-bitmask-constants
>> USPosition 0
>> USSize 1
>> PPosition 2
>> PSize 3
>> PMinSize 4
>> PMaxSize 5
>> PResizeInc 6
>> PAspect 7
>> PBaseSize 8
>> PWinGravity 9)
>
> Ah, where are the powers of 2 again?
Ohh, that was the input... |-(
--
Lisp: Powering `Impossible Thoughts since 1958
--
Posted via a free Usenet account from http://www.teranews.com
Tamas Papp wrote:
> I have a macro which defines constants as powers of two (for
> interfacing with xlib):
>
> (defmacro define-bitmask-constants (&rest name-power-pairs)
> "Define a list of constants from name-value pairs, raising 2 to
> the power value."
> (labels ((dbc (pairs)
> (case (length pairs)
> (0 nil)
> (1 (error "no power after ~a" (car name-power-pairs)))
> (t (destructuring-bind (name power &rest rest) pairs
> `((defconstant ,name (expt 2 ,power))
> ,@(dbc rest)))))))
> `(progn
> ,@(dbc name-power-pairs))))
>
> But when I apply it, the first argument is indented too much. For
> example,
>
> (define-bitmask-constants
> USPosition 0
> USSize 1
> PPosition 2
> PSize 3
> PMinSize 4
> PMaxSize 5
> PResizeInc 6
> PAspect 7
> PBaseSize 8
> PWinGravity 9)
>
> Any suggestions? This is cosmetic, but I would be interested to know
> why this occurs.
>
> Thanks,
>
> Tamas
I think replacing &rest with &body would make it.
Sacha
Sacha <····@address.spam> writes:
>> But when I apply it, the first argument is indented too much. For
>> example,
>>
>> (define-bitmask-constants USPosition 0
>> USSize 1
>> PPosition 2
>> PSize 3
>> PMinSize 4
>> PMaxSize 5
>> PResizeInc 6
>> PAspect 7
>> PBaseSize 8
>> PWinGravity 9)
>>
>> Any suggestions? This is cosmetic, but I would be interested to know
>> why this occurs.
>>
>> Thanks,
>>
>> Tamas
>
> I think replacing &rest with &body would make it.
>
> Sacha
Thanks Sacha,
Tamas