public inbox for
 help / color / mirror / Atom feed
From: Panicz Maciej Godek <>
Subject: Expansion of a renamed macro seems to break hygiene
Date: Wed, 5 Jan 2022 00:21:15 +0100	[thread overview]
Message-ID: <> (raw)

Since I've recently been spending a bit more time in Kawa, I started to
transplant my "idiocyncracies" from other Schemes that I've been using.

One of them is the definition of optional and keyword arguments to
functions. Similarly to Guile, Kawa uses a DSSSL or Common Lisp style of
providing keyword and optional arguments, which isn't something that I like
for two reasons:

- first, it makes functions definitions look very differently from usages
of those functions
- second, it introduces many (i.e. three) special symbols, for
distinguishing optional, keyword and rest arguments

Therefore, I prefer to write, say

(define (copy! from: source to: destination size: size := (default-size))

This introduces only one special symbol, namely :=.

 I wrote similar extensions for Guile and for Racket, which was easy,
because I could shadow the core bindings of the lambda and define forms
which expanded to those core forms. Guile allowed me to rename the bindings
(say, lambda/kw and define/kw) in the module's export spec.

I tried doing the same for Kawa. I wrote this module today:

When I ran a test:

(import (keyword-arguments))
(define/kw (f x := 5 y := 10 in: z := 15) (list x y z))

it worked as expected.

However, when I tried renaming the define/kw and lambda/kw forms to define
and lambda during import, i.e.

(import (rename (keyword-arguments) (define/kw define) (lambda/kw lambda)))

and then tried using the define form, as in, say

(define/kw (f x := 5 y := 10 in: z := 15) (list x y z))

it blew the stack. I suspect that the reason was that the define/kw macro
expanded not to the original Kawa's define form, but to the renamed
define/kw. I'm not sure how clear the standard is on this point, but I
think that it might be a wrong behavior.

I can easily find a workaround (because I saw that the Kawa's define form
expands to %define, and so I would do the same in my extension), but I
wonder if this behavior is intentional and whether it could possibly be

Best regards,

                 reply	other threads:[~2022-01-04 23:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='' \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).