[Larceny-users] Ticket 638
Lynn Winebarger
owinebar at gmail.com
Tue Apr 21 07:10:43 EDT 2009
On Tue, Apr 21, 2009 at 3:04 AM, Derick Eddington
<derick.eddington at gmail.com> wrote:
> On Mon, 2009-04-20 at 22:04 -0400, Lynn Winebarger wrote:
> [...]
> But for explicit phasing systems, such as Larceny and PLT, I don't think
> a result of #T makes sense because `cons' and `kons' are unbound at
> phase -1 and unbound identifiers are compared according to their
> spelling. If they are supposed to be bound, that's either implicit
> phasing or confusing syntax template semantics.
Right, PLT's explicit phasing is exactly why this is interesting. I
should have been clearer that the three points I offered are
hypothetical reasons for the inconsistency rather than expressions of
my preferences.
> I think Larceny's phase mismatch detection is very preferable to
> allowing separate namespaces (that would be very unSchemely) for
> different phases such that `cons' would be allowed unbound at phase -1
> but bound at the phases it's imported for. And this detection is
> consistent with the fact that R6RS requires preventing importing the
> same name but different bindings at different phases.
Ok, I hadn't noticed the latter restriction in R6RS.
>> There are multiple issues:
>> 1) The syntax violation is getting triggered too early.
>
> How can you tell?
>
>> There's an
>> echo of Will's complaint that R6RS requires compiling programs with
>> obvious errors to give error messages at run-time
>
> That temp2.sps is being compiled and run in the same process, so how can
> you tell when the error is happening? I think it probably actually is
> happening at expand-time.
Exactly - evidently the error should wait at least until it appears on
the right hand side of a macro definition. R6RS has a lot of
requirements like that - the compiler has to generate code that will
definitely signal an exception at run-time, even if it's provable at
compile time that the exception will be signaled.
>> 2) The binding is getting resolved too early. It shouldn't be
>> resolved until it appears on the right hand side of a syntax binding
>> form. Consider whether the following program should produce 'a or 7:
>
> Because Scheme is lexically scoped and maintaining that is a primary
> purpose of R6RS syntax templates, it's obvious to me that `foo' should
> be bound to a syntax object representing the identifier `x' from the
> lexical scope where that identifier occurs, and that identifier refers
> to the `x' imported from `(defines x)'.
>
The point of this hypothetical was whether it's the macro that's
hygeinic or the syntactic template. You're arguing for the template,
but I think it's arguable that the template does not become actual
source code until it's on the right hand side of a macro definition,
and so referential transparency should be "through" that macro
defintion, not the template.
> [...]
> IIUC, you're saying the syntax object returned from `helper' should
> refer to the `do-it' in the program. That would defeat the whole point
> of hygienic macros.
>
Again, you're referring to hygienic templates, not macros as such.
>> 3) It doesn't make a lot of sense to have free-identifier=? if you
>> can't create a free identifier without triggering an expand time
>> error.
>
> You can do that. Larceny's error is happening because the free
> identifiers have imported bindings in scope but not at the right phase
> level and so it's preventing separate namespaces from existing.
Then this goes back to point 1, the error should be signaled either
when the template is actually appears in a macro defintion or when it
appears as part of source code as a result of the macro invocation.
Before that, maybe it should just be a warning. Why cause an error if
the offending identifier never even appears in the output of the
macro?
Lynn
More information about the Larceny-users
mailing list