Hello all,
I've been playing around with creating circular lists (and learning racket
which has been quite fun), but I'm stumped on why the lazy version of
letrec-values is not producing a promise like the lazy version of letrec
does. With the lazy letrec I can create circular lists, but with the lazy
letrec-values I get #<undefined>. See the example below.

;;;;;;;;;;;;;;;;; example code ;;;;;;;;;;;;;;;;;;;;;;;;;
#lang lazy

;; create a circular list using letrec (this works)
(define example-working
  (letrec ([A (list 'a B)]
           [B (list 'b A)])
    B))
(displayln "Working Example:")
(displayln example-working)
(displayln (!! example-working))

; Prints...
;Working Example:
;(b #<promise:A>)
;#0=(b (a #0#))

;; create a circular list using letrec-values (this is broken)
(define example-broken
  (letrec-values ([(A) (values (list 'a B))]
                  [(B) (values (list 'b A))])
    B))
(displayln "Broken Example:")
(displayln example-broken)
(displayln (!! example-broken))

; Prints
;Broken Example:
;(b (a #<undefined>))
;(b (a #<undefined>))
;;;;;;;;;;;;;;;;; end code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

I realize that there are many different ways to generate circular lists,
but why doesn't this work? Am I misunderstanding something or is this a bug?

Thanks,
Luke
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to