On Sun, 13 Sep 2009 15:22:35 -0400, Brian Mastenbrook
<[email protected]> wrote:
> On Sep 13, 2009, at 2:04 PM, John Cowan wrote:
>
>> Abdulaziz Ghuloum scripsit:
>>
>>> I think one-pass gives you an approximation of let*-scoping
>>> semantics while two-pass gives you recursive bindings. For
>>> example, the following expression
>>>
>>> (let-syntax ((f (syntax-rules () ((_) 1))))
>>> (let ()
>>> (define (g) (f))
>>> (define (f) 2)
>>> (g)))
>>>
>>> evaluates to 1 in one-pass since at the time (f) is expanded,
>>> only the outer f is known. In two-pass, it evaluates to 2
>>> since (f) is expanded after the shadowing definition of f is
>>> found.
>>
>> On my system, at least, Bigloo returns 1; PLT, Gauche, Chicken, scsh,
>> Kawa, SISC, and Petite Chez all return 2; and Gambit and Guile return
>> syntax errors. None of these systems, AFAIK, are two-pass in the
>> sense
>> of R6RS.
Chez is a two pass system.
> You forgot to start Gambit in hygienic mode; it returns 2 as well.
>
> The issue of one-pass or two-pass has little to do with the example
> you gave. It's entirely equivalent to:
>
> (let-syntax ((f (syntax-rules () ((_) 1))))
> (let ()
> (letrec ((g (f))
> (f 2))
> (g))))
>
> ... so the syntax binding of `f' is not used at all. Bigloo's `let-
> syntax' is known to be broken. Guile is, well, Guile; I expect that
> one of the 2.0 series betas would return 2 as well, since the macro
> expander has been switched out for psyntax.
In my understanding of two-pass versus one-pass, it does make a difference
here. In a one-pass system, you don't have the LETREC or LETREC*
semantics. In the one pass semantics, you must expand the forms as you
encounter them. You do not differ the expansion. thus, you cannot collect
all the definitions into a single scope before applying them. A one-paas
is more like the following:
(letrec ([g (f)]) (letrec ([f (lambda () 2)]) ---))
unless I am missing something. I don't see how you can avoid passing over
some forms more than once if you don't want to do it this way.
Aaron W. Hsu
--
Of all tyrannies, a tyranny sincerely exercised for the good of its
victims may be the most oppressive. -- C. S. Lewis
_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss