[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Write a macro which defines a procedure

From: Arne Babenhauserheide
Subject: Re: Write a macro which defines a procedure
Date: Sat, 20 Jul 2019 09:04:56 +0200
User-agent: mu4e 1.2.0; emacs 26.1

zelphirkaltstahl <address@hidden> 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:

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:

Best wishes,
Unpolitisch sein
heißt politisch sein
ohne es zu merken

Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]