comp.lang.ada
 help / color / mirror / Atom feed
From: richw@ada-uts
Subject: Re: Orphaned Response
Date: Thu, 7-Aug-86 00:58:00 EDT	[thread overview]
Date: Thu Aug  7 00:58:00 1986
Message-ID: <4700074@ada-uts> (raw)
In-Reply-To: 679@EDU


>>  Wrong conclusion.  If a language allows the program you describe
>>  then any implementation that behaves the way you're worried about
>>  is wrong.

I'm not sure what you're saying; it seems clear to me that either (a)
Ada-with-procedure-pointers allows my program, i.e. the program
successfully compiles, or (b) the program is rejected by the compiler.
(a) leads lets users write unsafe programs; (b) complicates the
semantics of Ada and places serious restrictions on what you can do
with procedure pointers.  It's as simple as that.

To be honest, my intention was not to prove that the addition of
procedure pointers to Ada would necessarily make Ada an unsafe
langauge -- instead, I just wanted to show that there are indeed
non-trivial problems in adding procedure pointers to Ada.  These
problems have not been sufficiently considered in the notes I've read
to date.

For instance, as you pointed out, activation records could be
allocated on the heap.  While this is very well possible, the
question then arises as to who reclaims that storage.  Whereas
the user normally has control over garbage collection (if his
or her compiler even provides garbage collection; most don't)
via "pragma CONTROLLED" and UNCHECKED_DEALLOCATION, this would
not be the case for activation records placed in the heap --
the user would have no way of referring to "activation-record"
objects.  It seems that, without further additions to the language,
compilers would be forced to automatically reclaim heap-allocated
activation records -- while this is again possible, this would
complicate compilers quite a bit.  And if compilers did indeed
provide automatic garbage collection of these activation records,
this would have serious consequences for real-time applications
which could not afford unexpected, momentary lapses due to
garbage collection.  Remember, Ada was designed with real-time
applications in mind -- imagine your fighter-plane refusing to
take evasive actions because it needed to garbage collect.

As you can see, the addition of procedure pointers to Ada opens up
quite a can of worms.

To consider another alternative, yes, you could restrict procedure
pointers from being returned into a broader scope than the one in
which they're defined.  Such restrictions detract from the worth of
procedure pointers in Ada, though, and they also complicate the
semantic processing that compilers must perform.  So you do pay
prices.

In any case, I agree that the problems which crop up when consider-
ing adding procedure pointers to Ada aren't insurmountable.  I still
doubt that these problems are really worth tackling in the first place.
Your use of procedure pointers to limit scope is hardly the only way
to do so without resorting to the use of "globals"...

       reply	other threads:[~1986-08-07  4:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <679@EDU>
1986-08-07  4:58 ` richw [this message]
     [not found] <18077548@jade.UUCP>
1986-08-08 10:41 ` Orphaned Response kern
     [not found] <1701997413@950@ucbvax.Berke>
1986-06-02 19:08 ` GOODENOUGH@
     [not found] <1701997413@576@ucbvax/nerke>
1986-06-02 18:29 ` GOODENOUGH@
     [not found] <306@telesoft.UKE>
1986-03-18 16:55 ` stt
1985-12-31 21:40 Ada '88 musings stt
1986-01-20 17:47 ` Orphaned Response stt
     [not found] <690@lll-crg.UUCP>
1985-07-26 22:35 ` gjs
replies disabled

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