[plt-scheme] near-copy struct construction?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Tue Jan 27 21:52:52 EST 2004

You can define this with a macro, as long as you add `stuff' as an 
argument. Check out the docs on define-struct (and what is bound to 
`stuff' at expansion time).

Robby

On Jan 27, 2004, at 7:46 PM, Guillaume Marceau wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>
> Is there a way to copy struct with all fields but a few fields equal 
> their
> original value?
>
> In ocaml, this is the "with" operator ocaml for record constructors.
>
> I would call it 'make-struct-with', and it would behave as follow:
>
>> (define-struct stuff (a b c d e) (make-inspector))
>> (define s (make-stuff 1 2 3 4 5))
>> (struct->vector s)
> #6(struct:stuff 1 2 3 4 5)
>> (define new-s (make-struct-with s (c 'boo)))
>> (struct->vector new-s)
> #6(struct:stuff 1 2 boo 4 5)
>
>
> -- 
> "The thing I remember most about America is that it's silly.
>  That can be quite a relief at times."  -- Thom Yorke, Radiohead
>
> - Guillaume
>
>
>
-------
SII(SII)
&
((lambda (x) (x x)) (lambda (x) (x x)))



Posted on the users mailing list.