cisco / ChezScheme

Chez Scheme
Apache License 2.0
6.97k stars 983 forks source link

Why do identifier properties and compile-time values require explicitly capturing a `lookup` procedure? #749

Closed dpk closed 1 month ago

dpk commented 11 months ago

The Chez Scheme implementation of identifier properties and the more limited compile-time values requires the transformer to return a procedure which the expander in turn re-enters with a lookup (rho) procedure to find the compile-time value or the property value. Any helper procedure used by a transformer which has to look up this information has to be passed this procedure explicitly as well.

Meanwhile, the equivalent for compile-time values in Racket, syntax-local-value can simply be imported into a library. Guile has a similar feature, syntax-local-binding. Both are restricted to being called within macro transformers for obvious reasons.

Other than the fact that lookup/rho cannot be used outside a transformer call, and depends on state made available by the expander (which could be done using a parameter or some other dynamic state, for example), is there any reason for the design decision to require explicitly capturing the lookup procedure to access compile-time values and properties, rather than making an identifier-property-ref type procedure which can be in scope anywhere?

(I tried to add the label ‘question’ but couldn’t see how.)