Sure... Macros can produce any kind of code you need, including code
that defines other macros. For instance, here's something along the
lines of what you showed:
(defmacro define-bytes (prefix sizes)
(let ((x (make-symbol "X")))
(flet ((make-name (suffix)
(intern (concatenate 'string
(string prefix) "-"
(write-to-string suffix)))))
`(progn
,@(mapcar #'(lambda (size &aux (name (make-name size)))
`(defmacro ,name (,x)
`(the (signed-byte ,,size) ,',x)))
sizes)))))
CL-USER > (pprint (macroexpand-1 '(define-bytes foo (8 16 32))))
(PROGN
(DEFMACRO FOO-8 (#:X) `(THE (SIGNED-BYTE 8) #:X))
(DEFMACRO FOO-16 (#:X) `(THE (SIGNED-BYTE 16) #:X))
(DEFMACRO FOO-32 (#:X) `(THE (SIGNED-BYTE 32) #:X)))
Those nested backquotes can be tricky, and you might find it easier to
work with the list structure directly rather than with the backquote
"templates":
(defmacro define-bytes (prefix sizes)
(let ((x (make-symbol "X")))
(labels ((make-name (suffix)
(intern (concatenate 'string
(string prefix) "-"
(write-to-string suffix)))))
`(progn
,@(mapcar #'(lambda (size)
(list 'defmacro (make-name size) (list x)
`(the (signed-byte ,size) ,x)))
sizes)))))
//JT