[racket] shared and immutable structures

From: Stephen Chang (stchang at ccs.neu.edu)
Date: Tue Feb 1 10:39:31 EST 2011

So why wouldnt using a mutable struct work?

> (struct kons (first rest) #:transparent #:mutable)
> (shared ([a (kons 1 a)]) a)
#0=(kons 1 #0#)




On Tue, Feb 1, 2011 at 10:33 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> At Tue, 01 Feb 2011 10:14:57 -0500, David Van Horn wrote:
>>  > (shared ([a (cons 1 a)])
>>      a)
>> #0='(1 . #0#)
>>
>>  > (struct kons (first rest) #:transparent)
>>  > (shared ([a (kons 1 a)])
>>      a)
>> (kons 1 #<undefined>)
>>
>> Is there a way to get the kons structure to behave like cons?
>
> No. The `shared' form can only create cycles with mutable structures.
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>



Posted on the users mailing list.