From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by sourceware.org (Postfix) with ESMTPS id 7A52C3858402 for ; Tue, 4 Jan 2022 23:21:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7A52C3858402 Received: by mail-io1-xd30.google.com with SMTP id o7so44345889ioo.9 for ; Tue, 04 Jan 2022 15:21:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=xpWBrQtzhUViC8+Zo28GETssBW1qYzHQB6JU/8ybCow=; b=dXNFPCGDAYUeUhOXxPhyYscDY3LhrPstjEstBqfp0CCatyHnUxQRWQfkHfGWJByZ5B iGwgzyyBWNd/5xe6x33awHNdlMwl7SKa/vfHC37aQvOHYBWBmdX+IaUHRJFRArb/iEe7 xWybLpZ0wiXup74IXPRSE2HW4Z+9kcBL7y8k2RKgL04YeoNExlmICQbSDDUwl6rT0ozF +rjGFKLN+/D9/Ox0Sblq9lxAKY2t0sWQ1/m/3BFBeMPyzlmX12FaBHPC/C/OGN/LuV48 bbb9TR8RTOgSfyhFw5pg95xxQMtG9h2V9jA4W6bRhCeGgc6dLmhHOMD/DEwUvH5M/is+ xifQ== X-Gm-Message-State: AOAM533jsrLOthxIUi0MAwDYI7aBbX5lDsTs4sbfLwkivG0SztpxWr66 UocJDqXhIEJjES0d1bDZXhfVG89Mj4BxirsoVrshxCYYZ5Zvfw== X-Google-Smtp-Source: ABdhPJwUWQYwWOmsUri1V6bNWrCuRHSrKuc3K0UI54um0y1EL8KXrAEvhiOgDE+c2m2MDsfaGLA8eZYnSgSIb3zmjcg= X-Received: by 2002:a5d:9650:: with SMTP id d16mr23735956ios.15.1641338485717; Tue, 04 Jan 2022 15:21:25 -0800 (PST) MIME-Version: 1.0 From: Panicz Maciej Godek Date: Wed, 5 Jan 2022 00:21:15 +0100 Message-ID: Subject: Expansion of a renamed macro seems to break hygiene To: kawa@sourceware.org X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: kawa@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Kawa mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jan 2022 23:21:28 -0000 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: https://github.com/panicz/grasp-android/blob/master/stages/retreat/GRASP/src/keyword-arguments.scm When I ran a test: (import (keyword-arguments)) (define/kw (f x := 5 y := 10 in: z := 15) (list x y z)) (f) 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 fixed. Best regards, Panicz