comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: parent package referring to child
Date: Wed, 10 Oct 2007 23:12:16 -0500
Date: 2007-10-10T23:12:16-05:00	[thread overview]
Message-ID: <fek7ll$t11$1@jacob-sparre.dk> (raw)
In-Reply-To: 1192047607.865747.220890@50g2000hsm.googlegroups.com

"Adam Beneschan" <adam@irvine.com> wrote in message
news:1192047607.865747.220890@50g2000hsm.googlegroups.com...
> On Oct 10, 12:32 pm, Matthew Heaney <mhea...@on2.com> wrote:
...
> > No, that's wrong.  In this case you can use mode inout because type T
> > is tagged (meaning that it's passed by reference).
>
> I don't see what the parameter mode has to do with it.

The mode has nothing do to with it; but the rule is that a tagged incomplete
type (which is what you get in a limited view) can be used as a parameter.
See 3.101(8.2/2).

>  I can't find a rule that would make "procedure Op (O : in P.C.T);"
illegal.

It's the absence of a rule: see the only allowed uses for incomplete types:
see 3.10.1(5-9.4/2). Note that 3.10.1(9.4/2) says that no other uses are
allowed. Use as a parameter is not allowed for untagged types.

...
> Also, the "by reference" comment isn't relevant either.

It is relevant as it is the reason that tagged incomplete types can be used
as parameters (because the compiler doesn't need to know the real type in
order to know how it is passed as a parameter - this same property is needed
to be able to deal with classwide types which is why it is fundamental to
tagged types); you don't know that for untagged types so they aren't
allowed.

I think I was the originator of this idea; it allows you to make classwide
calls for objects of types that you don't actually know about. (I'm not sure
that it is as useful as I originally thought, but it certainly is a
less-restrictive rule.)

...
> > Try it!
>
> That doesn't seem to be particularly good advice.  You can "try it"
> only by running it through a compiler, but that still won't tell you
> whether the code is illegal because many compilers accept a lot of
> code that they shouldn't.  I know GNAT has accepted plenty of illegal
> code in the past.  (Some of the bugs have been fixed in later
> versions.)

I think Matt was trying more to convince the skeptical that this works. But
I agree that you can't rely only on a compiler to realize that this works;
it helps to know the rules and motivation.

                         Randy.





  reply	other threads:[~2007-10-11  4:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-10  6:23 parent package referring to child eliben
2007-10-10  9:07 ` Georg Bauhaus
2007-10-10  9:24   ` eliben
2007-10-10 14:46     ` Adam Beneschan
2007-10-10 19:26   ` Simon Wright
2007-10-10 14:59 ` Matthew Heaney
2007-10-10 18:54   ` Vadim Godunko
2007-10-10 19:32     ` Matthew Heaney
2007-10-10 20:20       ` Adam Beneschan
2007-10-11  4:12         ` Randy Brukardt [this message]
2007-10-11 15:21           ` Adam Beneschan
2007-10-19 12:45           ` Vadim Godunko
2007-10-10 19:51   ` Matthew Heaney
2007-10-10 17:06 ` Jeffrey R. Carter
2007-10-10 19:17 ` anon
2007-10-11  9:45 ` george
2007-10-12  4:15   ` Jeffrey R. Carter
2007-10-12  9:51     ` Georg Bauhaus
replies disabled

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