[racket] does anyone have an example of a closure cycle in zo-parse?
Do you mean the same `code' field but a different `gen-id' field? I
think that will never happen.
The `gen-id' field just makes the `eq?'-level identity of constant
closures more apparent (that is, two closures should have the same
`gen-id' if an only if they are `eq?'). At the same time, a `closure'
wrapper is generated by the compiler as soon as it sees a closed
`lambda' form, so the form wouldn't be referenced in multiple places
except through the `closure' wrapper.
At Sun, 8 May 2011 18:50:06 -0400, Danny Yoo wrote:
> In Racket 5.1.1's compiler/zo-parse module, I see that the
> documentation on the 'closure' structure says that there can be cycles
> due to recursive closure calling. I can see this, but I haven't been
> able to figure out why there would be different instances of closures
> with different gen-ids. Does anyone have an example of one?
>
> Here's the code I'm using to play with 5.1.1's compiler/zo-parse module.
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;;;;;;;;;;;;
> #lang racket/base
> (require compiler/zo-parse
> (for-syntax racket/base))
>
> (define (run-zo-parse stx)
> (parameterize ([current-namespace (make-base-namespace)])
> (let ([bc (compile stx)]
> [op (open-output-bytes)])
> (write bc op)
> (zo-parse (open-input-bytes (get-output-bytes op))))))
>
> ;; A cyclic structure should show here:
> (run-zo-parse #'(letrec ([g (lambda () (g))]) (g)))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;;;;;;;;;;;;;;;
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users