On Sep 14, 2009, at 12:54 AM, Brian Mastenbrook wrote:

> Chicken does this. The algorithm seems to be:
>
> * Start with an empty set of collected `define' forms, and an empty  
> set of collected `define-syntax' forms.
> * Examine each definition in turn.
> * If the definition is a `define', and there is a nonempty set of  
> `define-syntax' collected forms, convert this set into a `letrec- 
> syntax' form wrapping the following definitions and body forms.
> * If the definition is a `define-syntax' form, and there is a  
> nonempty set of `define' collected forms, convert this set into a  
> `letrec' form wrapping the following definitions and body forms.
> * Otherwise, collect the form.
> * After the last `define' or `define-syntax' form, clear any  
> remaining collected forms as above.

Thanks for the clarification about what Chicken does; which is  
different from the "one-pass" that I described earlier.

> I believe that Chicken is a faithful implementation of the one-pass  
> semantics in this case.

This one (as you described it) still does some amount of lookahead  
into the internal definitions in order to collect/categorize  
definitions.

[BTW, the term "two-pass" is a misnomer since it's not really two  
passes (I'm just tagging along in the term instead of nitpicking).   
One can implement the expansion of R6RS's internal definition in one  
recursive pass: when a variable definition is encountered, expand the  
rest; and when control returns, expand the right-hand-side  
expression.  In Ikarus, I keep an explicit queue instead of leaving it  
on the execution stack so that I can expand the expressions left-to- 
right or top-down instead of having them expanded in reverse order.   
This is only for debugging purposes so that earlier errors are  
reported first, otherwise, the recursive algorithm is pretty  
straightforward for implementing R6RS's internal/library/top-level  
definitions.]

Aziz,,,

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to