[racket] struct-copy with sub-types

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Fri Mar 25 11:32:11 EDT 2011

On Fri, Mar 25, 2011 at 10:29 AM, Pierpaolo Bernardi
<olopierpa at gmail.com> wrote:
> On Fri, Mar 25, 2011 at 16:17, Nadeem Abdul Hamid <nadeem at acm.org> wrote:
>> Ok, yes, on second thought, I guess it is fine. With your fix,
>>
>> (struct-copy sub (sub 1 2 3) [c 4])   ==> (sub 1 2 4)
>> (struct-copy sub (sub 1 2 3) [b 4])   ==> (sub 1 4 3)
>> (struct-copy base (sub 1 2 3) [b 4]) ===> (base 1 4)
>>
>> is that right? So that sentence applies to the third situation.
>>
>> I guess when the second one didn't work, I assumed somehow that "id"
>> could only be the struct type where the field was actually defined. So
>> it was a bug. Sorry for the confusion,
>
> Isn't the second case the case Robby said it still doesn't work?

Oh, sorry, yes: you'd have to write this:

  (struct-copy sub (sub 1 2 3) [b #:parent base 4])

or else it would be a syntax error.

Robby



Posted on the users mailing list.