comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: Classwide Parameter?
Date: Tue, 12 Oct 2004 10:53:44 +0200
Date: 2004-10-12T10:53:44+02:00	[thread overview]
Message-ID: <5720860.DVXme7QNW1@linux1.krischik.com> (raw)
In-Reply-To: ckg303$dbt$00$1@news.t-online.com

matthias_k wrote:

> Matthew Heaney wrote:
>> matthias_k <nospam@digitalraid.com> writes:
>> 
>> 
>>>Thanks for that answer. However, I'm still having problems (I have
>>>rewritten the code to be in one single package now):
>>>
>>><snip>
>>>package Graphics is
>>>
>>>    type Shape is abstract tagged null record;
>>>    procedure Draw (Obj: Shape'Class);
>> 
>> 
>> Get rid of this operation.  It's a "class-wide" operation (like a static
>> method in C++), and hence the operation isn't primitive for the type
>> (and therefore doesn't dispatch).

"static" would be a function in the same package but without any X or
X'Class parameter. It's more like non virtual function.

> Oha? I thought it would be analogous to 'virtual' in C++, not static.

I did the same mistake in the beginning. In Ada all operations defined in
the same package as the class are virtual.

> If I leave out the method completely, then this is not what I know as
> 'Inheritance' anymore.
> Shape is supposed to be an abstract base class, which -declares- (not
> necessarily -defines-) a common interface for its subtypes. The code I
> posted may not reflect this too well, it's just samplecode.
> I doubt -any- dynamic binding will happen when completely leaving out
> Shape's Draw method.

you need:

procedure Draw (Obj: Shape) is abstract;

which

> And btw.: What does dispatch mean? :) Is that the Ada term for dynamic
> binding?

That's right.

Martin

-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




  reply	other threads:[~2004-10-12  8:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-11 16:01 Classwide Parameter? matthias_k
2004-10-11 16:53 ` Matthew Heaney
2004-10-11 17:08   ` matthias_k
2004-10-11 19:16     ` Simon Wright
2004-10-11 22:53     ` Brian May
2004-10-12  2:29     ` Matthew Heaney
2004-10-12  8:01       ` matthias_k
2004-10-12  8:53         ` Martin Krischik [this message]
2004-10-12 13:10         ` Matthew Heaney
2004-10-12  7:59     ` Dmitry A. Kazakov
     [not found]       ` <ckg3h6$qau$03$1@news.t-online.com>
2004-10-12  8:14         ` matthias_k
2004-10-12 15:13           ` Dmitry A. Kazakov
2004-10-12  8:10     ` Martin Krischik
replies disabled

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