In Example 8.52 we noted that functional languages can safely use reference counts since the lack of

Question:

In Example 8.52 we noted that functional languages can safely use reference counts since the lack of an assignment statement prevents them from introducing circularity. This isn’t strictly true; constructs like the Lisp letrec can also be used to make cycles, so long as uses of circularly defined names are hidden inside lambda expressions in each definition:

(define foo (lambda () (letrec ((a (lambda (f) (if f #\A b))) (b (lambda (f) (if f #\B c))) (c (lambda (f) (if f #\C a)))) a)))

Each of the functions a, b, and c contains a reference to the next:

How might you address this circularity without giving up on reference counts?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: