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

Re: [Scheme-reports] ANN: first draft of R7RS small language available

On Thu, 21 Apr 2011 22:51:34 -0400, Alex Shinn <alexshinn@x> wrote:

> On Fri, Apr 22, 2011 at 12:25 AM, Aaron W. Hsu <arcfide@x>  
> wrote:
>> I am actually really curious about this. In every implementation with
>> which I am familiar, importing a binding from a library results in the
>> same lexical binding. I believe that Andre's second example with MATCH  
>> is
>> an interesting one and I am interested to know how you deal with such a
>> thing in Chibi. In fact, could you explain in detail how such an
>> implementation works when it doesn't actually result in the same lexical
>> bindings? How can it make the match example work?
> Of course this works in Chibi.  My own `match' macro, which
> is used pervasively in Chibi and Chicken, does the same thing.
> When I said that Chibi matches as though all identifiers are
> unbound in the top-level, that was just one way of looking at
> it which lets me claim compatibility without changing the
> text of the syntax-rules literal matching rule:
>   A subform in the input matches a literal identifier if and only
>   if it is an identifier and either both its occurrence in the
>   macro expression and its occurrence in the macro definition
>   have the same lexical binding, or the two identifiers are equal
>   and both have no lexical binding.
> Another way of looking at this is to change that rule with
> s/lexical/local/g.  In other words, all top-level bindings are
> equivalent for the purpose of literal matching.
> The implications for this are that while
>   (let ((else #f))
>     (cond (else (display "else clause matched"))))
> is required to not display anything as in R5RS,
>   (define else #f)
>   ...
>   (cond (else (display "else clause matched")))
> would display "else clause matched".  Because the
> else is not local to the usage in question, I think this
> is the more intuitive behavior.

Okay, you seem to be talking about the top-level here. I'm not talking
about the REPL top level when I ask the question above. I'm talking about
inside of a Chibi module; I think you are saying that, given two modules
which import the same third module, the resulting bindings in each of
these two modules are not lexically identical. So I don't understand how
this can result in something like the above working. Andre's example
illustrates what I would expect to go wrong in this case.

Regarding your actual response above, and how these things work at the
top-level, I am very surprised by your second example. I would argue that
"else" in the cond there must refer lexically to the defined "else" and
thus, should be the same as the let form. Indeed, this is basically what I
see in Chez Scheme and other Schemes with which I am familiar. In the
above semantics, how can I make cond *not* have an else clause at the REPL
if I don't want it to have one? Moreover, if I were to write my own
macros, how could I make it possible to do the equivalent for them, too?

	Aaron W. Hsu

Programming is just another word for the lost art of thinking.

Scheme-reports mailing list