Re: 7.0 wishlist?
- From: Owen Jacobson <angrybaldguy@xxxxxxxxx>
- Date: Thu, 13 Nov 2008 15:27:38 -0800 (PST)
On Nov 13, 5:48 pm, Andreas Leitgeb <a...@xxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Joshua Cranmer <Pidgeo...@xxxxxxxxxxxxxxx> wrote:
Note, for example, that
making a Square class extend a Rectangle (since a Square is-a Rectangle)
does not actually work since it would fail to match the Rectangle's
contract.
I may not understand your example in all its possible deepness, but
what type of rectangle-related contract do you have in mind, that is
not met by a square? I hope it is not something like "width!=height
must be allowed": such types of contracts would thwart almost every
"is-a" relation.
Square is-a rectangle doesn't work for mutable types: if you modify
the width of a rectangle, the contract is not such that the height may
change as well. Square is-a rectangle works fine for immutable types
and for case classes; in the former case, Square only expands the API
and replaces the constructor, and in the latter, modifying the
dimensions makes the object not-a Square any more (but still a
Rectangle).
Shapes and Animals are still stupid examples, mind.
-o
.
- Follow-Ups:
- Re: 7.0 wishlist?
- From: Joshua Cranmer
- Re: 7.0 wishlist?
- References:
- Re: 7.0 wishlist?
- From: Harold Yarmouth
- Re: 7.0 wishlist?
- From: Joshua Cranmer
- Re: 7.0 wishlist?
- From: Harold Yarmouth
- Re: 7.0 wishlist?
- From: Joshua Cranmer
- Re: 7.0 wishlist?
- From: Harold Yarmouth
- Re: 7.0 wishlist?
- From: Joshua Cranmer
- Re: 7.0 wishlist?
- From: Harold Yarmouth
- Re: 7.0 wishlist?
- From: Joshua Cranmer
- Re: 7.0 wishlist?
- From: Harold Yarmouth
- Re: 7.0 wishlist?
- From: Joshua Cranmer
- Re: 7.0 wishlist?
- From: Harold Yarmouth
- Re: 7.0 wishlist?
- From: Joshua Cranmer
- Re: 7.0 wishlist?
- From: Andreas Leitgeb
- Re: 7.0 wishlist?
- Prev by Date: Re: 7.0 wishlist?
- Next by Date: Re: Possible bug in Calendar
- Previous by thread: Re: Operator overloading [was Re: 7.0 wishlist?]
- Next by thread: Re: 7.0 wishlist?
- Index(es):
Relevant Pages
|