comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <dewar@gnat.com>
Subject: Re: Who is right? Gnat or http://www.adahome.com/articles/1998-02/ar_lessons95.html?
Date: 1999/04/07
Date: 1999-04-07T00:00:00+00:00	[thread overview]
Message-ID: <7egnbg$u7b$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 01be80c2$114e0890$c24d3a8b@m04w0588

In article <01be80c2$114e0890$c24d3a8b@m04w0588>,
  "Daniel Wengelin" <dawe@celsiustech.se> wrote:
> The ability to pass subprograms as parameters is one of
> the nicest features of Ada 95 (it didn't exist in Ada
> 83). But accessibility rules make it useless within a
> multi-tasking program.

Hmmm! I guess that means that Daniel thinks that procedure
pointers in C are also useless in multi-tasking programs!

The claim is very misleading. Remember this: the only time
that accessibility rules are an issue for procedure
parameters is for the case of nested procedures. To
eliminate the problem, make the procedures in question
global. Global procedures, as opposed to global variables,
are never a problem for tasking.

Now you can react and say, gosh, that's terrible not being
able to use pointers to local procedures in a completely
general manner, I can't live with that, the language is
useless. But then you are also saying that C, C++ and Java
are useless -- yes, I know some of the excessive rhetoric
from Ada fans seems to say that at times :-) But seriously,
we know that this is not the case!

P.S. GNAT contains a significant extension, namely the
Unrestricted_Access attribute for procedures, which
completely eliminates these accesibility checks for
procedures, and gives you the same functionality as
GNU C's nested procedures and procedure pointers. This
comes at a price:

(a) it is significantly non-portable. Some implementors
claimed it was impossible to provide this kind of
capability with displays, and this is one of the times
that the language design bent to the will of implementors.
Since some implementations (e.g. Aonix) still use displays
you cannot expect all Ada implementations to copy this
GNAT attribute.

(b) it is unsafe, since you can create dangling pointers,
and dangling procedure pointers are a particularly
unpleasant beast to have around!

Nevertheless it is a powerful facility. For a fairly
fundamental use of this facility in practice, see the
SPITBOL packages provided by GNAT.

Robert Dewar
Ada Core Technologies

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




      parent reply	other threads:[~1999-04-07  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-07  0:00 Who is right? Gnat or http://www.adahome.com/articles/1998-02/ar_lessons95.html? Daniel Wengelin
1999-04-07  0:00 ` Tucker Taft
1999-04-07  0:00 ` David C. Hoos, Sr.
1999-04-07  0:00   ` Daniel Wengelin
1999-04-07  0:00 ` Robert Dewar [this message]
replies disabled

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