[racket] does anyone have an example of a closure cycle in zo-parse?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon May 9 10:32:49 EDT 2011

And if you are looking for code that parses that way, the Racket
definition of map does. That's the main one Blake used to test his
changes in that area of the code.

Jay

2011/5/8 Matthew Flatt <mflatt at cs.utah.edu>:
> 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
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93



Posted on the users mailing list.