[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] miscmacros hygienic
From: |
Kon Lovett |
Subject: |
Re: [Chicken-users] miscmacros hygienic |
Date: |
Wed, 28 May 2008 21:05:28 -0700 |
On May 28, 2008, at 8:33 PM, Jim Ursetto wrote:
Thank you Jim for your recent life on the bleeding edge. (And Felix
for expanding space.) I haven't visited yet so anything I say is
subject to ignorance.
I ported miscmacros (attached) to the hygienic branch and had a couple
questions.
First, is anyone using miscmacros? I was wondering about the
following
proposed change to the anaphoric macros:
Current -> Proposed
(if* x y z) -> (if* (it x) y z)
(while* test body) -> (while* (it test) body)
(repeat* test body) -> (repeat* (it test) body)
I think it's nicer not to break hygiene by introducing a hidden 'it'
identifier--like dotimes does not. In the port I actually
implemented them
both ways; you just have to uncomment the desired behavior. Thoughts?
I use the "anaphoric" forms but not "in anger." Yeah, the above is
more Scheme-ish but I suggest leaving "it." Perhaps:
(if/let (it x) y z)
(while/let (it test) body)
...
or
(let/if (it x) y z)
(let/while (it test) body)
...
Also--the miscmacros module uses a few bindings from the chicken
module:
(import (only chicken
when unless handle-exceptions
let-optionals make-parameter))
However adding this import line to miscmacros is basically useless
(as far as I
can tell) because the macros are expanded in the caller's
environment, so the
caller is the one who needs to do the import from chicken.
I'd like to know the proper way to handle this, if any. Does the
caller
need to explicitly import any dependencies?
I hope not. Ahh, the return of the transitive monster.
That will be unworkable for the user.
Similarly, as while* actually expands into an invocation of if*, it
does
not work for the caller to do (import (only miscmacros while*)), as
the
if* in the resulting expansion of while* will be undefined.
So dependencies are not automatically imported? Hum, "hoisted by ..."
comes to mind.
In fact the following doesn't look hygienic at all:
#;1> (module foo ()
(import scheme (only miscmacros while*))
(define-syntax if*
(lambda (f r c) (error 'bad)))
(while* (it (> 0 5)) (display it)))
Error: during expansion of (if*1305 ...) - bad
Is this a bug or am I just confused?
Should a user module (program?) local definition, syntax or not,
override the dependent definitions in an imported form? Good question.
<snip>
Best Wishes,
Kon