comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: "limited with" packages
Date: Wed, 20 Jun 2007 09:32:37 -0700
Date: 2007-06-20T09:32:37-07:00	[thread overview]
Message-ID: <1182357157.972402.299280@g37g2000prf.googlegroups.com> (raw)
In-Reply-To: <1182355561.359900.160710@k79g2000hse.googlegroups.com>

On Jun 20, 9:06 am, adam.betts...@gmail.com wrote:

> Really thanks. I've spent a couple of hours banging my head about
> this, in the end I programmed around it. I can't believe the solution
> is so simple. Not to make excuses but I'm relatively new to Ada (few
> months), and I'm trying to use most of the advanced features as my
> project requires it. I think I lack a thorough understanding of how
> the Ada compiler works. So, does the "limited with" clause only apply
> at the spec level?

You wouldn't want to use it on a body.  "limited with" is a new
feature of Ada.  The purpose is to handle a situation where you want
to write a package P1 that uses types declared in P2, and similarly P2
that uses types declared in P1.  (You might have record structures in
P1 and P2 that point to each other.)  The problem was that you
couldn't compile P1 without compiling P2 first, and you couldn't
compile P2 without compiling P1 first, and you couldn't get a chicken
until you had the egg first, and ... you get the idea.  "limited with"
was a solution to this.  In your example, you can compile My_Package's
spec without compiling Other_Package first; at some point,
Other_Package will undergo a very simple scan just to see what type
names are available, and My_Package's spec can then use those type
names, but in a very restricted way---about the only thing you can do
is to declare an access type that points to it.  (In particular, I
believe that your function declaration that returns a type_one_pointer
is illegal, because the compiler won't know enough about
type_one_pointer at that point.  You'll need to move type_one_pointer
to My_Package.)  After you compile My_Package's spec, you can compile
Other_Package, and then you can compile the bodies.  Since
Other_Package has been compiled by that time, there's no longer any
need for a "limited with Other_Package"; at that point you will want
to do a normal "with".

I hope this helps give you a general idea of what's going on.

                    -- Adam







  reply	other threads:[~2007-06-20 16:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-20 13:20 "limited with" packages adam.betts155
2007-06-20 15:38 ` Adam Beneschan
2007-06-20 16:06   ` adam.betts155
2007-06-20 16:32     ` Adam Beneschan [this message]
2007-06-20 16:27   ` adam.betts155
2007-06-20 18:13     ` Adam Beneschan
2007-06-20 18:27       ` Anh Vo
2007-06-20 18:44         ` Adam Beneschan
2007-06-21  8:13         ` adam.betts155
2007-06-22  5:10           ` Simon Wright
replies disabled

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