comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Simple Question 3
Date: Mon, 15 Oct 2001 06:26:38 GMT
Date: 2001-10-15T06:26:38+00:00	[thread overview]
Message-ID: <3BCA818F.161376A1@acm.org> (raw)
In-Reply-To: 9qd2c9$4a2$1@news7.svr.pol.co.uk

Stephen Cole wrote:
> 
> "Jeffrey Carter" <jrcarter@acm.org> wrote in message
> news:3BC9FD23.ACEB872A@acm.org...
> >
> > We could perhaps be of more assistance if you could define what you
> > expect the compiler to do for
> >
> > X : Mytesttype2 := Unitc;
> >
> > What is the value of X after initialization? Specifically, what is the
> > value of X.C?
> >
> > --
> > Jeff Carter
> > "I fart in your general direction."
> > Monty Python & the Holy Grail
> 
> I would have thought that the compiler would have looked for a function
> called UnitC() that would return a type MyTesttype2. If it could not find
> one then it would flag a static match failure and so the whole problem of
> X.C being initialised would not have occured as it would not be allowed.

Unitc is a primitive operation of the root type. Primitive operations
are inherited by the child type if they are not overridden. However, the
inherited version of Unitc cannot know about the additional components
of the child type, so it must be overridden. Therefore, Ada requires the
function to be overridden.

The problem arises because a call to Unitc can still be a dispatching
call. You cannot guarantee that all calls will be determinable at
compile time. Therefore, a version of the function must exist for the
child type.

Of course, if you use composition rather than type extension and
dispatching you can obtain the same effect but deal with these details
however you like. The resulting software will be easier to read, as
well.

-- 
Jeff Carter
"I wave my private parts at your aunties."
Monty Python & the Holy Grail



  reply	other threads:[~2001-10-15  6:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-11 14:28 Simple Question 3 Stephen Cole
2001-10-11 22:41 ` tmoran
2001-10-12 11:33   ` Stephen Cole
2001-10-12 17:03     ` tmoran
2001-10-14  7:51     ` Jean-Marc Bourguet
2001-10-12 13:33 ` David C. Hoos
2001-10-14 18:53 ` Stephen Cole
2001-10-14 20:45   ` Vincent Marciante
2001-10-14 21:00   ` Jeffrey Carter
2001-10-14 22:08     ` Stephen Cole
2001-10-15  6:26       ` Jeffrey Carter [this message]
2001-10-14 21:15   ` Primitive operations and derived types (Was: Simple Question 3) Jacob Sparre Andersen
2001-10-14 21:42   ` Simple Question 3 tmoran
2001-10-14 22:30     ` Stephen Cole
replies disabled

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