comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: Non-philosophical definition of Eiffel?
Date: Thu, 31 Jul 2003 11:58:41 +0200
Date: 2003-07-31T11:58:41+02:00	[thread overview]
Message-ID: <91nhivgoeparbpt1984prf1o09sos9f9p5@4ax.com> (raw)
In-Reply-To: 1059583115.463164@master.nyc.kbcfp.com

On Wed, 30 Jul 2003 12:38:35 -0400, Hyman Rosen <hyrosen@mail.com>
wrote:

>Dmitry A. Kazakov wrote:
>> type Ellipse is ...;
>> function Resize (X : Ellipse;...) return Ellipse;
>> type Circle is new Ellipse ...;
>> function Resize (X : Circle;...) return Circle;
>>    -- Breaks LSP, not every circle, being resized yields a circle.
>
>We need to look at this without using common English words
>that will cause confusion:
>
>     type Base is ...;
>     function Affect(X : Base) return Base;
>     type Derived is new Base ...;
>     function Affect(X : Derived) return Derived;
>
>Now if I have a Derived object attached to a Base'Class
>reference, and I make a dispatching call, the Derived
>Affect will be called, will return a Derived object, and
>since a Derived object is a Base object, substitutability
>is satisfied.

No it isn't. You forgot semantics. LSP is all about semantics. The
problem is that Affect returning Derived just cannot be implemented in
Cricle/Ellipse case. This problem appears each time a derived type is
a specialization of the base. Specialization breaks out-methods.
Covariant result is a case of out-method. Period.

> If the Derived type, or the Base type, is
>supposed to maintain certain invariants but the methods
>fail to do that, then the methods are in error, but that
>has nothing to do with LSP.

What does it mean to "be in error"? The contract of Base does not
mention "being in error". So it violates the contract and thus LSP.

>> ---- LSP-abstinence-syndrome
>> Hey, "computer circles" are not "computer ellipses"!
>
>This is the correct answer.

Yes, but it does not imply that Circle shall not be a subtype of
Ellipse. In a real system it will, because code reuse is more
important than far-fetched absolute LSP. It is clear that an absolute
substitutability cannot be enfoced by any means. The real solution is
a context-dependent substitutability and type systems helping in
checking it as much as possible.

>> The real problem is that it is fundametally unsolvable. One could
>> easily see that LSP is mathematically unsound, should one try to
>> define it formally.
>
>Nonsense. The only unsoundness here is the confusion between
>abstract notions and and how they map into computer code. Your
>use of the words "Ellipse" and "Circle" and "Resize" demonstrates
>this. What is the computer-ellipse? If it is an object which has
>independently resizable axes, and a computer-circle does not, then
>a computer-circle is not a computer-ellipse, and can't be used in
>places where computer-ellipses are expected. On the other hand, if
>a computer-ellipse is an immutable object with a pair of axis sizes,
>then a computer-circle can be written to fit that interface as well,
>and can be used where a computer-ellipse is expected.

This is one of many ways of defending [absolute] LSP. Surely if you
are dealing with something so airy which cannot be expressed
mathematically, then you simply cannot disprove it mathematically.
(:-))

>This is all perfectly obvious and has been talked about over and
>over again. It's simply a matter of asking what operations a base
>type supports, and whether a derived type can support all of the
>same operations. Any notion that derivation within computer code
>must somehow model abstract notions of the real world is wrong,
>and leads into confusion and error.

This exactly means to be mathematically unsound.

>> Ada does this. It is a class-wide argument.
>
>Does it? Do you have an example? I'm not sure that it's the
>same thing, but we'll see.

Class-wide arguments are not controlled, they are not inherited when
you derive. Because a class-wide argument is a closure of the set of
all derived types.

type Base is tagged ...;
procedure Foo (X : Base'Class);
type Derived is new Base ...;
   -- Foo is same for Derived and it is not inherited

One could say that class-wide arguments are contravariant, but this
would be imprecise, because no type conversion to the base type
happens. However, the effect is same [as long as redispatch supported
through an embedded type tag] 

> > So subtype Postive is Integer ...; inevitable breaks LSP.
> > You just have to decide what do you want, [an absolute]
> > LSP or positive numbers. I vote for positive numbers.
>
>I forget. Does Ada let you pass a Positive object to a
>procedure expecting an Integer out parameter,

Yes.

> and range
>check the assignment, or does it forbid such a call? If
>it's the former, then LSP is in fact preserved, in that
>the same set of operations are permitted.

It is so:

1. if Constraint_Error is a part of the contract of the procedure then
LSP is preserved with this regard. As I said to add all imaginable
exceptions to all contracts is a possible way. Unfortunately it is
great burden and it erodes the idea of checkability.

2. if Constraint_Error is not in the contract. then LSP is violated.

>The operation
>may throw an exception, but it's present. That's the same
>thing as implementing Circle.Resize and having it throw
>if the two axes are not specified to bethe same size.

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



  reply	other threads:[~2003-07-31  9:58 UTC|newest]

Thread overview: 158+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-21  2:10 Ariane5 FAQ Alexandre E. Kopilovitch
2003-07-21 14:52 ` Hyman Rosen
2003-07-21 15:54   ` Vinzent Hoefler
2003-07-21 18:01     ` Hyman Rosen
2003-07-21 18:10       ` Vinzent Hoefler
2003-07-21 18:49         ` Hyman Rosen
2003-07-21 19:13           ` Vinzent Hoefler
2003-07-21 19:43             ` Hyman Rosen
2003-07-21 20:46               ` Vinzent Hoefler
2003-07-22  2:04                 ` Hyman Rosen
2003-07-22  5:12                   ` Robert I. Eachus
2003-07-22 19:09                     ` Hyman Rosen
2003-07-22  8:03                   ` Leif Roar Moldskred
2003-07-22  9:00                   ` Vinzent Hoefler
2003-07-23  0:13                     ` Hyman Rosen
2003-07-23  0:31                       ` Bobby D. Bryant
2003-07-23 13:53                         ` Hyman Rosen
2003-07-24 16:35                           ` Richard Riehle
2003-07-25  1:21                             ` Alexander Kopilovitch
2003-07-25  4:26                               ` Richard Riehle
2003-07-25 12:35                               ` Hyman Rosen
2003-07-25 15:47                                 ` Robert I. Eachus
2003-07-25 16:51                                   ` Hyman Rosen
2003-07-25 18:44                                     ` Robert I. Eachus
2003-07-25 21:08                                       ` Simon Wright
2003-07-26  1:02                                         ` Robert I. Eachus
2003-07-26  2:44                                     ` Alexander Kopilovitch
2003-07-27 17:05                                       ` Hyman Rosen
2003-07-27 22:19                                         ` Alexander Kopilovitch
2003-07-28  1:17                                           ` Berend de Boer
2003-07-28  2:39                                             ` Robert I. Eachus
2003-07-28  3:16                                               ` Hyman Rosen
2003-07-28 17:34                                                 ` Mike Silva
2003-07-28 18:03                                                   ` Hyman Rosen
2003-07-29  0:41                                               ` Alexander Kopilovitch
2003-07-29 16:24                                                 ` Robert I. Eachus
2003-07-30  0:53                                                   ` Alexander Kopilovitch
2003-07-31 21:41                                                     ` Robert I. Eachus
2003-08-01 20:19                                                       ` Alexander Kopilovitch
2003-07-29  4:43                                               ` Richard Riehle
2003-07-29  6:06                                                 ` Hyman Rosen
2003-07-29  8:06                                                   ` Vinzent Hoefler
2003-07-29 19:42                                                     ` Berend de Boer
2003-07-29 21:14                                                       ` Robert I. Eachus
2003-07-30  1:13                                                         ` Berend de Boer
2003-07-30 12:58                                                   ` Richard Riehle
2003-07-30 15:04                                                     ` Hyman Rosen
2003-07-29 19:46                                                 ` Berend de Boer
2003-07-30  6:19                                                   ` Richard Riehle
2003-07-30  7:31                                                     ` Hyman Rosen
2003-07-30 13:03                                                       ` Richard Riehle
2003-07-30 13:16                                                         ` Vinzent Hoefler
2003-07-30 15:06                                                           ` Hyman Rosen
2003-07-30 15:15                                                             ` Vinzent Hoefler
2003-07-30 16:46                                                               ` Hyman Rosen
2003-07-30 16:54                                                                 ` Vinzent Hoefler
2003-07-31  8:28                                                                   ` Dmitry A. Kazakov
2003-07-31  9:36                                                                     ` Vinzent Hoefler
2003-07-31 16:28                                                                     ` Warren W. Gay VE3WWG
2003-07-29 19:34                                               ` Berend de Boer
2003-07-29 20:49                                                 ` Simon Wright
2003-07-29 21:52                                                 ` Robert I. Eachus
2003-07-28 18:01                                             ` Non-philosophical definition of Eiffel? (was: Re: Ariane5 FAQ) Alexander Kopilovitch
2003-07-28 18:18                                               ` Non-philosophical definition of Eiffel? Hyman Rosen
2003-07-29  8:43                                                 ` Dmitry A. Kazakov
2003-07-29 13:43                                                   ` Hyman Rosen
2003-07-29 14:56                                                     ` Dmitry A. Kazakov
2003-07-29 16:35                                                       ` Hyman Rosen
2003-07-29 21:39                                                         ` Jim Rogers
2003-07-29 22:33                                                           ` Hyman Rosen
2003-07-30  8:48                                                             ` Pascal Obry
2003-07-30 15:19                                                               ` Hyman Rosen
2003-07-30 18:47                                                                 ` Frank J. Lhota
2003-07-30 19:24                                                                   ` Hyman Rosen
2003-08-04 18:15                                                                   ` Robert Spooner
2003-07-29 22:02                                                         ` Matthew Woodcraft
2003-07-30  9:19                                                         ` Dmitry A. Kazakov
2003-07-30 16:38                                                           ` Hyman Rosen
2003-07-31  9:58                                                             ` Dmitry A. Kazakov [this message]
2003-07-31 15:49                                                               ` Hyman Rosen
2003-08-01  7:57                                                                 ` Dmitry A. Kazakov
2003-08-01 13:31                                                                   ` Hyman Rosen
2003-07-29 19:58                                                 ` Berend de Boer
2003-07-29 20:33                                                   ` Hyman Rosen
2003-07-30  1:20                                                     ` Berend de Boer
2003-07-30  1:49                                                       ` Hyman Rosen
2003-07-30  2:52                                                         ` Berend de Boer
2003-07-30  4:33                                                           ` Hyman Rosen
2003-07-30  4:40                                                           ` Hyman Rosen
2003-07-30 13:16                                                           ` Matthew Heaney
2003-07-30 20:08                                                             ` Berend de Boer
2003-07-30  3:03                                                         ` Berend de Boer
2003-07-30  4:31                                                           ` Hyman Rosen
2003-07-30 20:20                                                             ` Berend de Boer
2003-07-30 21:05                                                               ` Hyman Rosen
2003-07-29 19:51                                               ` Berend de Boer
2003-07-28  2:11                                           ` Ariane5 FAQ Hyman Rosen
2003-07-25 17:39                                 ` Mike Silva
2003-07-25 21:53                                 ` John R. Strohm
2003-07-22 18:29                   ` Mike Silva
2003-07-22 18:50                     ` Hyman Rosen
2003-07-22 19:00                       ` Bobby D. Bryant
2003-07-22 20:47                       ` Mike Silva
2003-07-22 21:11                         ` Hyman Rosen
2003-07-22 21:38                           ` Bobby D. Bryant
2003-07-23 13:56                             ` Hyman Rosen
2003-07-22 21:52                   ` Larry Elmore
2003-07-23 14:11                     ` Hyman Rosen
2003-07-23 15:08                       ` Vinzent Hoefler
2003-07-23 17:48                         ` Hyman Rosen
2003-07-23 18:42                           ` Robert I. Eachus
2003-07-23 20:18                             ` Hyman Rosen
2003-07-23 22:58                               ` Robert I. Eachus
2003-07-24  1:42                                 ` Hyman Rosen
2003-07-24  5:24                                   ` Mike Silva
2003-07-24  9:57                           ` Vinzent Hoefler
2003-07-24 13:52                             ` Hyman Rosen
2003-07-24 15:00                               ` Vinzent Hoefler
2003-07-23 20:33                       ` Mike Silva
2003-07-23 21:35                         ` Hyman Rosen
2003-07-23 23:10                           ` Robert I. Eachus
2003-07-24  5:16                           ` Mike Silva
2003-07-22  4:57                 ` Richard Riehle
2003-07-22  9:00                   ` Vinzent Hoefler
2003-07-22  9:03                   ` John McCabe
2003-07-22 12:28                   ` Marin David Condic
2003-07-23 19:40               ` Simon Wright
2003-07-22  3:11             ` Robert I. Eachus
2003-07-22  9:05               ` John McCabe
2003-07-22  9:38                 ` Bobby D. Bryant
2003-07-22 16:38               ` Robert I. Eachus
2003-07-21 22:03           ` Bobby D. Bryant
2003-07-22  1:57             ` Hyman Rosen
2003-07-21 18:56         ` Francisco Malpartida
2003-07-22  2:22           ` Hyman Rosen
2003-07-22  7:19             ` Tarjei T. Jensen
2003-07-22 19:06               ` Hyman Rosen
2003-07-22 21:24                 ` Robert I. Eachus
2003-07-23 11:55                   ` Tarjei T. Jensen
2003-07-23 19:24                     ` Robert I. Eachus
2003-07-24  0:36                       ` Bobby D. Bryant
2003-07-21 22:00       ` Bobby D. Bryant
2003-07-22  1:59         ` Hyman Rosen
2003-07-22  9:07           ` John McCabe
2003-07-22 13:25             ` Hyman Rosen
2003-07-22  0:16       ` Alexander Kopilovitch
2003-07-22  1:45         ` Hyman Rosen
2003-07-22  7:21           ` Tarjei T. Jensen
2003-07-21 23:24   ` Alexander Kopilovitch
2003-07-22  1:53     ` Hyman Rosen
2003-07-22 16:35       ` Robert I. Eachus
2003-07-22 18:36       ` Mike Silva
2003-07-22 19:23         ` Hyman Rosen
2003-07-22 21:50           ` Robert I. Eachus
2003-07-23 14:21             ` Hyman Rosen
2003-07-23 19:56               ` Robert I. Eachus
2003-07-23 20:26                 ` Hyman Rosen
2003-07-23 23:14                   ` Robert I. Eachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox