Re: Mutability
Re: Mutability
- Subject: Re: Mutability
- From: John Hörnkvist <email@hidden>
- Date: Wed, 21 Nov 2001 21:19:37 +0100
On Wednesday, November 21, 2001, at 08:34 , John C. Randolph wrote:
Since I implemented this category of NSObject, everything in my code is
capable of behaving as a collection of a single object. Now, suppose I
have code that expects its parameter to be an NSArray, and I pass it a
single object instead. I contend that if the method in question
demands that its parameter must *be* an array, instead of demanding
that it can *act as* an array, then it's being needlessly particular.
This is well known among type theorists; the type system you're after is
called "Matching". Read 'Subtyping is not a good "Match" for
object-oriented languages' by Kim B. Bruce, Leaf Petersen, Adrian Fiech
or 'On subtyping and matching' by Martin Abadi and Luca Cardelli.
Subtyping and inheritance are convenient ways to describe what an object
can do, but not a good way to specify requirements.
Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com