Hi folks,
I am a bit stuck with macro writing. I'd like to translate this:
(with-output-as-presentation1 (:stream t :type tt :object ttt) (print object) (bla bla))
into this:
(WITH-OUTPUT-AS-PRESENTATION (T TT TTT) (PRINT OBJECT) (BLA BLA))
All I found was this:
(defun find-key (key liste)
(second (member key liste)))
(defmacro with-output-as-presentation1 ((&rest arg) &rest body)
(let ((stream1 (find-key ':stream arg))
(type1 (find-key ':type arg))
(object1 (find-key ':object arg)))
`(with-output-as-presentation (,stream1 ,type1 ,object1)
,@body)))
Looks very ugly to me. I couldn't figure out a way to use keywords in this macro.
Could any helpful soul help me what to look for ? Thanks for any help/hints !!
---
Daniel K.Schneider, TECFA (Educational Technologies and Learning)
Faculte de Psychologie et des Sciences de l'Education, University of Geneva,
9 route de Drize, 1227 Carouge(Switzerland),
Phone: (..41) 22 705 9694, Fax: (..41) 22 342 89 24
Internet: ········@divsun.unige.ch (and various national nets) | if reply
X400: S=schneide;OU=divsun;O=unige;PRMD=switch;ADMD=arcom;C=ch | does not
uucp: mcvax!cui!divsun.unige.ch!shneider | work, try
BITNET: ········@cgeuge51 | one of
DECNET: UGUN2A::SCHNEIDE (local Swiss) | these
In article <······················@news.unige.ch> ········@divsun.unige.ch
(SCHNEIDER daniel) writes:
>
> Hi folks,
>
> I am a bit stuck with macro writing. I'd like to translate this:
>
> (with-output-as-presentation1 (:stream t :type tt :object ttt)
> (print object) (bla bla))
>
> into this:
>
> (WITH-OUTPUT-AS-PRESENTATION (T TT TTT) (PRINT OBJECT) (BLA BLA))
How about
(defmacro with-output-as-presentation1 ((&key stream type object) &body body)
`(with-output-as-presentation (,stream ,type ,object) ,@body))
-- Frank Yellin
··@lucid.com
From: Daniel Nesmith
Subject: Re: Need help with macro writing
Date:
Message-ID: <24163@sbsvax.cs.uni-sb.de>
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
In article <······················@news.unige.ch>
········@divsun.unige.ch (SCHNEIDER daniel) writes:
I am a bit stuck with macro writing. I'd like to translate this:
(with-output-as-presentation1 (:stream t :type tt :object ttt) (print object) (bla bla))
into this:
(WITH-OUTPUT-AS-PRESENTATION (T TT TTT) (PRINT OBJECT) (BLA BLA))
You can use &KEY arguments in sublists of the argument lists for macros:
(defmacro with-output-as-presentation1 ((&key stream type object) &body body)
`(with-output-as-presentation (,stream ,type ,object) ,@body))
--
Simon.
In article <···················@liasg2.epfl.ch> ·····@lia.di.epfl.ch (Simon Leinen) writes:
>In article <······················@news.unige.ch>
>········@divsun.unige.ch (SCHNEIDER daniel) writes:
>
> I am a bit stuck with macro writing. I'd like to translate this:
>
> (with-output-as-presentation1 (:stream t :type tt :object ttt) (print object) (bla bla))
>
> into this:
>
> (WITH-OUTPUT-AS-PRESENTATION (T TT TTT) (PRINT OBJECT) (BLA BLA))
>
>You can use &KEY arguments in sublists of the argument lists for macros:
>
>(defmacro with-output-as-presentation1 ((&key stream type object) &body body)
> `(with-output-as-presentation (,stream ,type ,object) ,@body))
>--
>Simon.
You've aroused my curiousity -- Why? WITH-OUTPUT-AS-PRESENTATION
already takes keyword arguments in the style of your w-o-a-p1,
both in Symbolics Dynamic Windows and CLIM.
Pete.
Date: Tue, 2 Feb 1993 10:34 EST
From: Pete Grant <·····@pentagon-gw.army.mil>
In article <···················@liasg2.epfl.ch> ·····@lia.di.epfl.ch (Simon Leinen) writes:
>In article <······················@news.unige.ch>
>········@divsun.unige.ch (SCHNEIDER daniel) writes:
>
> I am a bit stuck with macro writing. I'd like to translate this:
>
> (with-output-as-presentation1 (:stream t :type tt :object ttt) (print object) (bla bla))
>
> into this:
>
> (WITH-OUTPUT-AS-PRESENTATION (T TT TTT) (PRINT OBJECT) (BLA BLA))
>
>You can use &KEY arguments in sublists of the argument lists for macros:
>
>(defmacro with-output-as-presentation1 ((&key stream type object) &body body)
> `(with-output-as-presentation (,stream ,type ,object) ,@body))
>--
>Simon.
You've aroused my curiousity -- Why? WITH-OUTPUT-AS-PRESENTATION
already takes keyword arguments in the style of your w-o-a-p1,
both in Symbolics Dynamic Windows and CLIM.
CLIM 2.0 takes stream, object, and type as required arguments. This is
because they were, in fact, already required for WITH-OUTPUT-AS-PRESENTATION
to do anything useful, so it was pointless for them to be keyword arguments.