[racket] Are there any functional structs in Racket

From: Nikita B. Zuev (nikitazu at gmail.com)
Date: Thu Oct 21 01:16:54 EDT 2010

Thank you all for your replies. I somehow missed `struct-copy', this
is exactly what I wanted. Bad thing I can't pass lambda to it like:

(struct-copy person
             myperson
             (age (lambda (age) (+ age 1))))


p.s.
About names `person/age' vs `person-with-age', maybe `person<-age'
it's like arrow says to us: take this new age and update person with
it.

2010/10/20 Matthias Felleisen <matthias at ccs.neu.edu>:
>
> Should be doable:
>
>> (set a-world ufo wings [right 'damaged] [left  'broken])
>
> is the most likely syntax I anticipate.
>
>
>
> On Oct 20, 2010, at 2:50 PM, <engineer at alum.mit.edu> wrote:
>
>> Are you all also considering some way to conveniently update more than one
>> at a time?  Functional style is still much more cumbersome than mutation
>> style.
>>
>> (set (set a-world ufo wings right 'damaged) ufo wings left 'broken)
>> starts to get cumbersome quickly.
>>
>> Is something like the below possible?  Is it scalable/manageable?  Maybe it
>> needs more grouping symbols like a cond clause.
>>
>> (set a-world ufo wings right 'damaged
>>                       left  'broken)
>>
>> -Paul
>>
>>> -----Original Message-----
>>> From: users-bounces at racket-lang.org [mailto:users-bounces at racket-lang.org]
>>> On Behalf Of Matthias Felleisen
>>> Sent: Wednesday, October 20, 2010 2:30 PM
>>> To: Tony Garnock-Jones
>>> Cc: Nikita B. Zuev; users at racket-lang.org
>>> Subject: Re: [racket] Are there any functional structs in Racket
>>>
>>>
>>>
>>> I have a prototype that supports syntax like this one:
>>>
>>> (dot a-world ufo wings left)
>>>
>>> which would select the left field of a wings field in a ufo field of a
>>> world struct.
>>>
>>> Similarly,
>>>
>>> (set a-world ufo wings left 'broken)
>>>
>>> would be a functional update.
>>>
>>> I intend to add it into the 2htdp languages.
>>>
>>>
>>>
>>>
>>>
>>> On Oct 20, 2010, at 2:21 PM, Tony Garnock-Jones wrote:
>>>
>>>> Stephen Bloch wrote:
>>>>> person-age-set
>>>>> set-person-age (without the !)
>>>>> person-with-age
>>>>
>>>> I like this last one, especially if it were possible to use the old
>>> abbreviation of "/" for "-with-":
>>>>
>>>> (person/age p 25)
>>>>
>>>> Tony
>>>>
>>>> _________________________________________________
>>>> For list-related administrative tasks:
>>>> http://lists.racket-lang.org/listinfo/users
>>>
>>> _________________________________________________
>>>  For list-related administrative tasks:
>>>  http://lists.racket-lang.org/listinfo/users
>>
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://lists.racket-lang.org/listinfo/users
>
>



-- 
--
Regards,
Nikita B. Zuev


Posted on the users mailing list.