Re: [racket-users] Re: Functional object-oriented programming

2017-02-08 Thread Steve Byan's Lists
> On Feb 8, 2017, at 9:05 PM, Philip McGrath wrote: > Personally, I tend to end up defining helper functions to do functional > update (often with optional keyword arguments to address the > fields-that-stay-the-same issue). Generics in the sense of racket/generic can

Re: [racket-users] Re: Functional object-oriented programming

2017-02-08 Thread Philip McGrath
Note, though, that struct-copy needs to be given the type of the resulting structure statically, at compile time, and "the result of *struct-expr* can be an instance of a sub-type of *id*, but the resulting copy is an immediate instance of *id* (not the sub-type)." [1] If you have a complex

Re: [racket-users] Re: Functional object-oriented programming

2017-02-08 Thread Steve Byan's Lists
Matthias, thanks for the confirmation that macros are the answer. Yes, mutation could be simpler. I'm learning more doing it functionally. Alex, thanks for pointing out struct-copy. I hadn't read that part of the Racket Guide yet. Would it be possible to write a macro that when invoked within

[racket-users] Re: Functional object-oriented programming

2017-02-08 Thread Alex Harsanyi
Structures support this style of updating: (struct foo (bar baz) #:transparent) (define one (foo "hello" 1)) ;; Copy all fields from "one" and update baz to 2 (define two (struct-copy foo one (baz 2))) They also have immutable fields by default. Best Regards, Alex. -- You