Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- From: ulf@xxxxxxxxx
- Date: 28 Aug 2006 15:37:14 -0700
Dmitry A. Kazakov wrote:
...
Yes, sure, sorry for my sloppy language. The mapping (monomorphism) has to
preserve operations of interest defined on the set.
The next Q is of course: which operations? how the set of interesting
operations determined/defined?
...
Fundamentally:
class T = { S | S<:T } -- A set of all types derived from T, including T
Now class S is a subset of class T, but S is not necessarily a subset of T.
So you have type T besides class T, where class T is built from type T
(and its subtypes). This reminds me of the Ada9x model.
Obviously then a subclass is a subset of the superclass.
Since you also say below that a type is more than a set of values, we
have as a third set the set of T-values.
class T != type T != valueset T
...
Set of Circle instances is NOT a subset of the set of Ellipse instances
AND set of circles in mathematics is a subset of the set of ellipses in
mathematics
=> OO-abstractions Circle/Ellipse != mathematical concept of
circle/ellipse
No, there is no any contradiction between OO and mathematics.
I didn't say there is a contradiction, I meant, they are different
things. The origin of the difference is that mathematical objects are
Platonic, stateless & behaviorless things, whereas the object
abstraction in OO includes mutable state and behavior. Naturally the
classification of different things may produce different classification
hierarchies.
Whether the
set of Circles is a proper subset of the set of Ellipses does not influence
the fact that the properties of these two sets are not inclusion related.
Set of properties /= set of values. A type is sufficiently more than a set
of values, it has operation.
Set + operations, that's an algebra. So the question how subtypes and
supertypes relate should be: are they subalgebras?
I thought in the OO paradigm, it is the objects that have the
operations (and hence, I read, the appropriate mathematical model for
objects would be coalgebras). Saying that a type has operations sounds
more like the ADT paradigm (the model of an ADT is a algebra).
Ah, it is a very interesting issue: whether pre-/post conditions could be
replaced by types. This could be considered as a sort of Hilbert's program
for types system. (:-)) Independently on how realistic it be for daily
programming, the question is whether type theory plays similar role for
programming as set theory for mathematics.
8^)
... Are you a generic-methods-detached-from-objects
fan? Or are you thinking at the level of OOPL-compilers' implementation
of message sends as subroutine invocations with "this" as an additional
hidden parameter?
The latter:
SetFoci : Shape x {(a,b)} -> Shape
... Or in other words, SetFoci is a triple method:
1. in-method of Shape in the first argument
2. in-method of {(a,b)} in the second argument
3. out-method of Shape in the result
IC. Yes, this is consistent with regarding types as algebras (the ADT
paradigm), just extended by subtypes (subalgebras) and dynamic
dispatch.
Regards,
Ulf Schünemann
.
- Follow-Ups:
- Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- From: Dmitry A. Kazakov
- Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- References:
- Re: delegation vs. inheritance
- From: ulf
- Re: delegation vs. inheritance
- From: S Perryman
- Re: delegation vs. inheritance
- From: Mark Nicholls
- Re: delegation vs. inheritance
- From: S Perryman
- Re: delegation vs. inheritance
- From: Mark Nicholls
- Re: delegation vs. inheritance
- From: S Perryman
- Re: delegation vs. inheritance
- From: Mark Nicholls
- Type substitutability [LONG] (Was: delegation vs. inheritance)
- From: S Perryman
- Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- From: Mark Nicholls
- Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- From: Dmitry A. Kazakov
- Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- From: Dmitry A. Kazakov
- Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- From: Mark Nicholls
- Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- From: Dmitry A. Kazakov
- Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- From: ulf
- Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- From: Dmitry A. Kazakov
- Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- From: ulf
- Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- From: Dmitry A. Kazakov
- Re: delegation vs. inheritance
- Prev by Date: Re: selective access to different classes
- Next by Date: Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- Previous by thread: Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- Next by thread: Re: Type substitutability [LONG] (Was: delegation vs. inheritance)
- Index(es):
Relevant Pages
|