home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!math.fu-berlin.de!ira.uka.de!Germany.EU.net!sbsvax!cs.uni-sb.de!nesmith
- From: nesmith@cs.uni-sb.de (Daniel Nesmith)
- Newsgroups: comp.lang.lisp
- Subject: Re: Need help with macro writing
- Message-ID: <24163@sbsvax.cs.uni-sb.de>
- Date: 27 Jan 93 01:52:25 GMT
- References: <1993Jan26.215013.12107@news.unige.ch>
- Sender: news@sbsvax.cs.uni-sb.de
- Organization: Computer Science, University of the Saarland, Germany
- Lines: 17
-
- Here's a suggestion (using woap as an abbreviation):
-
- ; first woap1 swaps the body and the keys but getting rid of the enclosing list around
- ; the keywords
- > (defmacro woap1 (keywordlist &body body) `(woap2 ,body ,@keywordlist))
- WOAP1
- ; now get values of the keyword arguments, swap them with the body, splice into body
- > (defmacro woap2 (bodylist &key stream type object)
- `(woap (,stream ,type ,object) ,@bodylist))
- WOAP2
- ;; now test
- > (macroexpand-1 '(woap1 (:stream t :type tt :object ttt) (print object) (bla bla)))
- (WOAP2 ((PRINT OBJECT) (BLA BLA)) :STREAM T :TYPE TT :OBJECT TTT)
- T
- > (macroexpand-1 *)
- (WOAP (T TT TTT) (PRINT OBJECT) (BLA BLA))
- T
-