This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Per Bothner wrote:
> David St-Hilaire wrote:
>> I'm completely new to kawa and I have a few questions.
>
> Welcome!
>
>> I wrote a simple macro which is:
>>
>> (define-macro (pp arg)
>> `(begin (display ,arg) (newline)))
>
> This is a FAQ (though alas Kawa doesn't have an FAQ list).
> Answer: Don't use define-macro or defmacro.
> Instead use define-syntax:
>
> (define-syntax pp
> (syntax-rules ()
> ((pp arg) (begin (display arg) (newline)))))
Ok thanks! Since I mostly used gambit before, I'm more used to define-macro
style macros! Lets say, for example, that I want to have an ugly imperative
style 'for macro like:
(define-macro (for init limit . exps)
(let ((var (gensym 'i))
(loop (gensym 'loop)))
`(let ,loop ((,var ,init))
(if (< ,var ,limit)
(begin ,@exps
(,loop (+ ,var 1)))))))
then, in the define-syntax style, would the macro:
(define-syntax for
(syntax-rules ()
((_ init limit exp1 . exps)
(let loop ((var init))
(if (< var limit)
(begin (begin exp1 . exps)
(loop (+ var 1))))))))
be equivalent...? Sorry for theses newb questions, I just want to make sure that
I got it right! ^_^
Thank you and happy scheming! ^_^Y
David
Attachment:
signature.asc
Description: OpenPGP digital signature
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |