Version 1.1 of acs/ac-00077.txt

Unformatted version of acs/ac-00077.txt version 1.1
Other versions for file acs/ac-00077.txt

!standard B.01(46)          03-09-12 AC95-00077/01
!class confirmation 03-09-12
!status received no action 03-09-12
!status received 03-09-05
!subject Pragma export on overloaded subprograms

!topic pragma export on overloaded subprograms
!reference B.1(46)
!from Dan Eilers 09-05-03

RM B.1(46) notes that interfacing pragmas can denote more than
one entity in the case of overloading, and such a pragma applies
to all the denoted entities.

In such a case, is a call to the named entity expected
to call each and all of the overloaded entities?

   package pak is
      procedure p1;
      procedure p1(x: integer);
      pragma export(ada, p1);      -- applied to overloaded entity
   end pak;

   with text_io; use text_io;
   package body pak is
      procedure p1 is
         put_line("first one called");

      procedure p1(x: integer) is
         put_line("second one called");
   end pak;

   with pak;
   procedure main is
      procedure p1;
      pragma import(ada, p1);
      p1;  -- what should this print?


From: Tucker Taft
Sent: Friday, September 5, 2003  1:08 PM

> In such a case, is a call to the named entity expected
> to call each and all of the overloaded entities?


I base this answer on the Robert's Rule of ARM Interpretation,
saying that interpretations that have silly consequences are
always wrong ;-).

More seriously...

This sort of export would probably only make sense
if the language to which you are exporting also supports
overloading (e.g. Java or C++ or Ada).  Exporting multiple
overloaded entities to a language like C using the same external_name
would almost certainly result in a link-time error, or perhaps
a failure in the compiler back end or assembler.
Similarly, exporting multiple procedures to any language
using the same link_name would result in a similar failure.

Going the other direction, I have used import on a set
of overloaded specifications when importing from C to
handle C functions that take a variable number of arguments
(e.g. printf).

In this example, you are exporting to Ada, and not even
specifying an external_name, so this should have essentially
no special run-time effect, other than to allow the caller to bypass
normal visibility rules.  However, it is possible that this
would fail for some Ada compilers, depending on how they choose
the link-name in the presence of an Export pragma.


Questions? Ask the ACAA Technical Agent