Newsgroups: comp.lang.c++,comp.object,comp.theory,comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!cmcl2.nyu.edu!news.sprintlink.net!news-pen-16.sprintlink.net!news-pull.sprintlink.net!news.sprintlink.net!news-dc-9.sprintlink.net!news.maxwell.syr.edu!newsfeeds.sol.net!hammer.uoregon.edu!zephyr.texoma.net!uunet!in1.uu.net!128.100.1.3!utcsri!info.ecf!doylep
From: doylep@ecf.toronto.edu (Patrick Doyle)
Subject: Re: Opinions on Ellipse-Circle dilemma?
Sender: news@ecf.toronto.edu (News Administrator)
Message-ID: <E5IC0y.G9F@ecf.toronto.edu>
Date: Wed, 12 Feb 1997 20:38:58 GMT
X-Nntp-Posting-Host: spark21.ecf
References: <5d4fmf$7gk@bagan.srce.hr> <32FA2A1C.6B31@arscorp.com> <5dm3g8$pr6@news2.delphi.com> <32ffa121.20952788@news.igs.net>
Organization: University of Toronto, Engineering Computing Facility
Lines: 50
Xref: glinda.oz.cs.cmu.edu comp.lang.c++:247506 comp.object:61065 comp.theory:17926 comp.lang.smalltalk:51490

In article <32ffa121.20952788@news.igs.net>,
Matt Timmermans <mtimmerm@microstar.com> wrote:
>
>So I put it to you, OO language authors, that if one can't make circle
>a subclass of ellipse, then it is a deficiency of the language, not
>the programmer.

  Well, yes and no.  I don't think that the inability to model a circle
as a _subclass_ of an ellipse is a deficiency.  Just because a circle IS
an ellipse doesn't mean that a circle class has to be a subclass of an
ellipse class.

  (In the following discussion, I am going to restrict myself to definitions
of ellipse and circle class for which the circle cannot be expressed as
a subclass of the ellipse.)

  The way I see it is this: in a functional language, you can provide a
function that "resizes" a circle by taking that circle as a parameter and
returning an ellipse.  You could do that in OOP as well: have a member
function that returns an ellipse that represents the circle after a stretch.

  Now consider member functions whose side-effects affect only the object
of which they are a member.  These can be modeled in functional languages
like this:

    f: C x P1 x P2 x ... x Pn  ->  C

  where C is the class of the object in question, and Pi is the class if the
ith parameter.  Say we have a function "stretch" that takes two real
parameters to specify the stretch in the X and Y directions.  It would
look like this:

    stretch: Ellipse x Real x Real  ->  Ellipse 

  If Circle is a subclass of Ellipse, it must satisfy this:

    stretch: Circle x Real x Real  ->  Circle

  which could not be satisfied any better in a functional language than
in an OO language.

  You may argue that it's a flaw in the language to require such a function
to exist.  Well, perhaps you would have a point there.  I don't have a good
answer to that one.  :-)

 -PD
-- 
--
Patrick Doyle
doylep@ecf.utoronto.ca
