[plt-scheme] Structure design, Immutable vs Mutable
John Clements
clements at brinckerhoff.org
Wed Sep 26 17:07:15 EDT 2007
On Sep 26, 2007, at 1:11 PM, Matthias Felleisen wrote:
>
> One specific point: I don't understand why you speak of subtypes
> in your message. I consider this issue entirely orthogonal.
I think that Henk is pointing out the fact that immutable objects
lead to more object creation, which highlights the importance of the
"factory problem"; that is, you need a factory method or an abstract
factory in order to create these objects.
Of course, the factory problem is certainly not limited to state-
passing style and its derivatives.
John Clements
>
> On Sep 26, 2007, at 1:53 PM, Henk Boom wrote:
>>
>> Another problem I see with subclasses is if I have a body method
>> which
>> moves a body by some distance.
>>
>> ;move-body: body vect-2d -> body
>>
>> This would create a new body with a changed position but all the old
>> fields copied over. However, if I have a player object, I would have
>> to override this method even though the behaviour for moving
>> player is
>> not that different, just because it would need to know to return a
>> player instead of a body (and copy the extra fields over).
>>
>> I feel like there is some conceptual leap I have not made yet. Are
>> there ways around these problems, or should I give up and move
>> back to
>> using mutation for this? Any suggestions would be appreciated.
>>
>> Henk Boom
>> _________________________________________________
>> For list-related administrative tasks:
>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2223 bytes
Desc: not available
Url : http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20070926/4f7f6771/smime-0001.bin
More information about the plt-scheme
mailing list