comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: Simple Question 3
Date: Sun, 14 Oct 2001 21:42:22 GMT
Date: 2001-10-14T21:42:22+00:00	[thread overview]
Message-ID: <2Fny7.17385$gT6.10077588@news1.rdc1.sfba.home.com> (raw)
In-Reply-To: 9qcmt9$8n1$1@newsg1.svr.pol.co.uk

> question of what a primitive operation is! Is it a function/procedure which
> takes a derived type parameter and/or returns a derived type? Or is it just
> functions which return a derived type only?
  The former.
> Why does returning a derived type seem to have
> more rules about what must be later declared in a derived type, than
> function/procedures that just take that derived type as a parameter?
> ...
> The way the compiler is behaving, its as if it only takes into account
> "out" parameters and does not care what "in" parameters look like.
  If an object of MyTestType1 is an input parameter to a function or
procedure, it's safe to inherit since the function/procedure will simply
not know about, and thus ignore, any later extensions in objects of
type MyTestType2.  If it's an output result, however, the function
or procedure needs to be able to create an object with all of its
extensions values.  That is only possible if the function/procedure
is declared after MyTestType2 is declared, so it knows about those
extensions and can set them to appropriate values.

>    function UnitA(a: MyTestType1) return Integer;
>    function UnitB(a: MyTestType1) return MyTestType1;
>    function UnitC return MyTestType1;
> UnitA() does not get flagged by the compiler as needing to be declared for
> MyTestType2. But UnitB() and UnitC() do! But they all hold enough type
> information for the compiler to be "intelligent" enough to know where static
> matching takes place or not.
  Yes indeed, the compiler does know whether static matching takes place.
It sounds like you want the compiler to flag any *use* of UnitB or UnitC
where the left side of the assignment statement does not match, but
you want the compiler to allow the *declaration*.  Right?
  If you were painting the floor in a room, you might like to paint a
thin part just inside the doorway, knowing that you could step over it
and get out of the room.  The compiler is saying, "whoa, you can't
start your painting from just inside the doorway because you'll paint
yourself into a corner".  It's easy enough to avoid the problem by
standing outside the doorway to do your painting.  Similarly, as
pointed out by Jean-Marc Bourguet, there are easy ways to declare Unit
as a non-primitive operation.



  parent reply	other threads:[~2001-10-14 21:42 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
2001-10-14 21:15   ` Primitive operations and derived types (Was: Simple Question 3) Jacob Sparre Andersen
2001-10-14 21:42   ` tmoran [this message]
2001-10-14 22:30     ` Simple Question 3 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