comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Ada OO
Date: 1996/11/25
Date: 1996-11-25T00:00:00+00:00	[thread overview]
Message-ID: <E1FMLp.1rp@world.std.com> (raw)
In-Reply-To: 57aq7s$30j@yuggoth.ucsb.edu


In article <57aq7s$30j@yuggoth.ucsb.edu>,
Graham Hughes  <graham.hughes@resnet.ucsb.edu> wrote:
>- From what I've seen, Ada OO is very similar to CLOS; 

The syntax is similar, but other than that, they are not similar.
CLOS is vastly more powerful, and more complicated, than Ada
(or any other OO language I've ever used).

In particular, CLOS has multi-methods, whereas Ada does not.

>Given this, how are C++-style virtual methods defined?  The stuff I've
>looked at implied that all subprograms defined in the package spec are
>virtual, and pure virtual methods are achieved by (appending?
>prepending?) abstract to the definition.

That's right -- if one or more parameters are of type T, and T is
tagged, and the procedure is in the same package as T, then it's virtual
(which Ada calls "dispatching").  And right, pure virtual is pretty much
the same thing as abstract.  Dispatching-on-function-result is something
C++ doesn't have.  Also, Ada has class-wide parameters -- a procedure
with class-wide parameters is not dispatching (unless some other
parameter makes it so).

>With CLOS, all defmethod (or is it defgeneric? been a while) methods are
                                                ^^^^^^^^^^^^
Yeah, me too.  I haven't used it since it was called "Flavors".
>effectively virtual, and pure virtual methods are just a defgeneric (?)
>with no body definitions.  Is this the way Ada OO works?

Well, sort of.  But in CLOS the methods are scattered all over,
whereever the programmer chooses.  In Ada, they're collected together in
a single package.

>Finally, re: the abstract; is it needed in the package body, or can it
>be ommitted?

Umm.  Not sure what you mean.  Can you give an example?  Usually,
"abstract" is placed on the type, and on some or all of its "methods",
and the type is *usually* in a package spec, not a package body.  And if
the method is abstract, it has no body in the package body.

- Bob




  reply	other threads:[~1996-11-25  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-25  0:00 Ada OO Graham Hughes
1996-11-25  0:00 ` Robert A Duff [this message]
1996-11-25  0:00   ` Graham Hughes
  -- strict thread matches above, loose matches on Subject: below --
2002-10-08  2:17 Rick Duley
2002-10-08  9:28 ` John McCabe
2002-10-08  9:54 ` John McCabe
2002-10-08 18:37   ` tmoran
     [not found] <F44Lnlyg35sQtgTIFpr0000279d@hotmail.com>
2002-10-08  3:01 ` David C. Hoos, Sr.
replies disabled

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