Julian Graham <jool...@gmail.com> writes: > This does strike me as a serious problem (and it's a spanner in the > works for implementing R6RS libraries). In effect, isn't the bug > saying that Guile's syncase macros aren't totally hygienic? That is, > in my example, if you provide your own binding for `foo-function' in > the REPL environment, then that will be used in the evaluation of the > transformed expression instead of the one in `(foo-module)', which is > certainly *not* the intent of the macro author.
Completely agree. I don't think there's any doubt that current behaviour is wrong. > However, as a novice who's spent some time poking around in > ice-9/boot-9.scm and `(ice-9 syncase)', I'm sort of confused about why > this is hard -- isn't this metadata available? The transformer should > have access to the closure in which it was created, and at creation > time, we certainly know which identifiers are free and which ones > aren't -- and we can look up the variables bound to the free ones in > the transformer's lexical closure. The problem is some combination of - how lexical identifiers are memoized (as a pair of numbers I, J, meaning the Ith variable in the Jth level up from the current lexical environment) - the fact that at any given point, the evaluator is only aware of one lexical environment - that the macro transformation process doesn't memoize top-level variables at the time of the transformation. I would guess it's mostly the last point. Regards, Neil