[racket-dev] shared no longer works on cons?!?

From: Shriram Krishnamurthi (sk at cs.brown.edu)
Date: Thu Oct 20 22:38:40 EDT 2011

According to my class notes from last year, the following examples
worked just fine in ASL:

(define web-colors
  (shared ([W (cons "white" G)]
           [G (cons "grey" W)])
    W))

; Will fail with error:
; (length web-colors)

(check-expect (equal? web-colors (rest web-colors)) false)
(check-expect (equal? web-colors (rest (rest web-colors))) true)

(check-expect (first web-colors) "white")
(check-expect (first (rest web-colors)) "grey")
(check-expect (first (rest (rest web-colors))) "white")
(check-expect (first (rest (rest (rest web-colors)))) "grey")
(check-expect (first (rest (rest (rest (rest web-colors))))) "white")
(check-expect (first (rest (rest (rest (rest (rest web-colors)))))) "grey")

Yet none of these work any longer:

> (first web-colors)
first: expects a non-empty list; given (shared ((-0- (cons "white"
(cons "grey" -0-)))) -0-)
> (rest web-colors)
rest: expects a non-empty list; given (shared ((-0- (cons "white"
(cons "grey" -0-)))) -0-)

When did this change occur?  And more importantly, what is the use of
letting cons to be written inside shared if you can't extract it?  How
else is one supposed to extract from cons if not using first/rest?

(Oddly, list-ref seems to work for extraction even though first and
rest do not.  I can anticipate numerous questions -- to which I don't
know the answer -- as to why this is the case.)

Several of my next few lectures depend on this working, so I'm a
little dismayed by this.

Shriram


Posted on the dev mailing list.