Hello Arne! Thanks for posting those links!
I think your "already defined macro check" is part of what I was looking for. I say part, because I was looking for something, that probably does not exist: Something that checks for existing macros and for existing procedures or other after compile-time defined things. However, the macro runs before those things are even evaluated, so I guess the only option would be to inspect the code and then find out what is defined. This is not really practical. So now I think that your check is actually as far as one can reasonably go. Regards, Zelphir On 7/20/19 6:00 PM, guile-user-requ...@gnu.org wrote: > Message: 2 > Date: Sat, 20 Jul 2019 09:04:56 +0200 > From: Arne Babenhauserheide <arne_...@web.de> > To: guile-user@gnu.org > Subject: Re: Write a macro which defines a procedure > Message-ID: <87sgr1nq5d....@web.de> > Content-Type: text/plain; charset="utf-8" > > > zelphirkaltstahl <zelphirkaltst...@posteo.de> writes: > >> Hi Guile Users, >> >> I want to write a macro, which creates a procedure of given name, >> where the given name is a not yet defined identifier. >> Here is what I have so far: > … > >> Anyway, can you help me out writing the macro, fixing at least the 2 >> issues or direct me to a tutorial, which covers how to write a macro >> which gives basically a new define form? > I can’t debug your form right now, but I can give you an example where I > created macros to write macros: > > https://bitbucket.org/ArneBab/wisp/src/5e860c746ee02c764bf378aeb8f436a1a341bd5c/examples/enter-three-witches.scm#lines-209 > > The Enter-Macro defines a macro which outputs its arguments as text. > > It took me some time to get it right, but it works pretty well. > > Bits and pieces: > - check for the presence of a macro-binding: > (syntax-case x () > ((_ (name more ...) b ...) > ; new binding: only create it if the binding is not already a macro > (not (eq? 'macro (syntax-local-binding (syntax name)))) > > - stay on the same level: > #'(begin … > > (this is originally written in wisp and then transformed to scheme for > easier sharing with other schemers: > https://bitbucket.org/ArneBab/wisp/src/5e860c746ee02c764bf378aeb8f436a1a341bd5c/examples/enter-three-witches.w#lines-209 > ) > > Best wishes, > Arne