comp.lang.ada
 help / color / mirror / Atom feed
From: emery@MITRE-BEDFORD.ARPA (Emery)
Subject: using <subprogram>'address for callback
Date: Wed, 16-Sep-87 09:13:47 EDT	[thread overview]
Date: Wed Sep 16 09:13:47 1987
Message-ID: <8709161313.AA01450@mitre-bedford.ARPA> (raw)

It should be clear that passing <subprogram>'address to X windows is at best
non-portable.  (A bit of history:  subprogram variables are expressly forbidden
by the language requirements, Steelman Paragraph 5D.  Don't blame Ada the 
language for implementing Steelman the Requirements...)   

There are some significant potential problems in using <subprogram>'address
for 'callback'.  I've used this trick on Verdix, and noted it as non-portable,
but I have found some (perfectly reasonable) problems.  In some instances, 
when procedure foo is invoked by C, I get program_error, due to the elaboration
check.  In general, an Ada program is responsible for insuring that subprograms
get elaborated before they are executed, and the language requires this check.
C, or some other non-Ada language, doesn't know how to play this game, and 
therefore when the C program invoked the Ada subprogram, I got the exception,
because the C program didn't know how to tell the Ada program that it had been
elaborated.  In my instance, I was able to swear on a stack of Ada reference
manuals that the subprogram had been elaborated before it was called by C, and
applied "pragma suppress(elaboration_check);" to the subprogram, and everything
worked ok.

The moral of the story is that if you do something non-portable (and possibly
erroneous) in Ada, you are not guaranteed that it will always work.  For a
(potential) standard, such as X windows binding, relying on such tricks as
passing <subprogram>'address is clearly unacceptable, due to the portability
problems, and some of the other similar problems with the Ada semantics,
such as elaboration checks.

				dave emery
				MITRE Ada Skills Center
				emery@mitre-bedford.arpa

             reply	other threads:[~1987-09-16 13:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1987-09-16 13:13 Emery [this message]
  -- strict thread matches above, loose matches on Subject: below --
1987-09-16 18:55 using <subprogram>'address for callback "LT Scott A. Norton, USN"
1987-09-17 19:30 Mike Feldman
replies disabled

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