[racket] struct-copy with sub-types

From: Pierpaolo Bernardi (olopierpa at gmail.com)
Date: Fri Mar 25 08:52:39 EDT 2011

On Wed, Mar 23, 2011 at 00:49, Nadeem Abdul Hamid <nadeem at acm.org> wrote:
> Is there anything like struct-copy that works to functionally update a
> field value in a structure, where the field happens to be defined in
> the super-type? In the example below, I want to "functionally update"
> a field of the sub structure inherited from the base definition...
> (struct base (a b) #:transparent)
> (struct sub base (c) #:transparent)
> (define S (sub 1 2 3))
> (struct-copy sub S [c 4]) ; works
> ; doesn't work: (struct-copy sub S [b 4])
> (struct-copy base S [b 4]) ; produces a base, not sub

No answers?

it looks to me that

(struct-copy sub S [b 4])

should work, but it doesn't.  Isn't this a bug?

If it is not considered a bug, maybe the docs need a clarification?


Posted on the users mailing list.