Re: Type substitutability [LONG] (Was: delegation vs. inheritance)



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

.



Relevant Pages

  • Re: In the Matter of Herb Schildt: a Detailed Analysis of "C: The Complete Nonsense"
    ... world of mathematics the integers are a subset of the real numbers. ... When I used machine language, ... got assembler (later on in my first computer science class) I debugged ... types in programming languages differ from numbers as they exist ...
    (comp.lang.c)
  • Re: thought: "traditional" vs "programmer" math?...
    ... in particular, I am left thinking that, although both make use of math, ... beginner in physics and not yet even a beginner at what people who ... actually do mathematics would call mathematics. ... object-oriented programming paradigm. ...
    (sci.math)
  • Re: A question about thinking abstractly....
    ... you might as well say civil engineering is applied mathematics. ... I've been a fan of proofs of correctness (though this says little as I ... bending the definition of programming to near breasking point. ... I think lots of people care. ...
    (comp.programming)
  • Re: Programming is the Engineering Discipline of the Science that is Mathematics
    ... between math and other scientific areas. ... Science is a methodology for study that is intimately anchored ... Mathematics can hardly defined by its usefulness as usefulness is ... Software engineering, or simply programming, is the engineering ...
    (comp.databases.theory)
  • Re: thought: "traditional" vs "programmer" math?...
    ... in particular, I am left thinking that, although both make use of math, the ... beginner in physics and not yet even a beginner at what people who ... actually do mathematics would call mathematics. ... object-oriented programming paradigm. ...
    (sci.math)