Rickard Nilsson | 23 Dec 01:00
Picon

Re: Scala Object Notation ( SCON? )

On Sat, 22 Dec 2007 22:55:12 +0100, Tony Morris <tmorris <at> tmorris.net>  
wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Rickard Nilsson wrote:
>> Another related thing I wish for is some lightweight
>> syntax for using case classes as immutable records,
>> (in Haskell-style, among others).
>>
>> So following your example I would like to do:
>>
>>   val p = Person {
>>     name = "Peter"
>>     age = 20
>>     ...
>>   }
>>
>>   val q = p { name = "Rickard" }
>>
>> where p gets all the attributes from p, with the
>> name updated. I would find this very useful. Any
>> suggestions for doing something similar without
>> any new special syntax?
>>
>>
>>   / Rickard
>
>
> The Haskell-record syntax (or similar) would be great! In the meantime,
> I have been writing a function for each field. For your example, I would
> write name: Person -> String -> Person

Yes, that is probably the best I could do for the moment.

   / Rickard


Gmane