comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: Access to procedures
Date: 1999/06/25
Date: 1999-06-25T00:00:00+00:00	[thread overview]
Message-ID: <7l0chu$9bv$1@nnrp1.deja.com> (raw)
In-Reply-To: 37737285.5CF9ED5F@Maths.UniNe.CH

In article <37737285.5CF9ED5F@Maths.UniNe.CH>,
  Gautier <Gautier.deMontmollin@Maths.UniNe.CH> wrote:

> *But* whatever the way I nest and subtype the things, the compiler
> (GNAT) tells me (certainly with good reasons):
>
> "subprogram must not be deeper than access type"
>
> even when it doesn't seem depper at all! So, my question is:
> how to do it ?

Heh. I stumbled into the same problem about a year ago when I was first
working on OpenToken. (I'm pretty sure it really is the same problem
this time. :-)  ). OpenToken uses procedure accesses to allow users to
supply their own text feeder functions; a rough equivalent to lex's
"input()" routine.

What had confused me was that it seemed like a procedure declared in the
main procedure should be at the same "level" as a procedure (or access
type) declared in a package spec/body. However, that is not the case. In
fact, someone was kind enough to point out that it is quite possible to
call the main procedure recursively.

Requiring that folks use "'Unchecked_Access" or declare the accessed
procedure in a package spec is really not all that bad. I've found that
kind of restriction is really more of a pain for my test drivers than it
is for actual client code.

One slightly different approach that OpenToken takes is to declare the
access type inside of a *generic* package. That way you only have to
worry about the "level" of the procedure being as high as the
*instantiation* of the generic. If any other part of your package would
make sense as a generic, you may consider this approach.

--
T.E.D.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




  parent reply	other threads:[~1999-06-25  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-25  0:00 Access to procedures Gautier
1999-06-25  0:00 ` Ehud Lamm
1999-06-25  0:00 ` Ted Dennison [this message]
1999-06-25  0:00 ` David Botton
1999-06-25  0:00 ` tmoran
1999-06-26  0:00   ` Gautier
1999-06-26  0:00     ` Brian Rogoff
1999-06-26  0:00     ` tmoran
1999-06-27  0:00       ` David Botton
1999-06-27  0:00         ` Brian Rogoff
1999-06-27  0:00           ` tmoran
1999-06-28  0:00             ` Gautier
1999-06-25  0:00 ` David Botton
1999-06-26  0:00 ` David C. Hoos, Sr.
replies disabled

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