comp.lang.ada
 help / color / mirror / Atom feed
* GnatLib vs. pragma Interface
@ 1997-08-20  0:00 Steve Whalen
  1997-08-20  0:00 ` Robert Dewar
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Whalen @ 1997-08-20  0:00 UTC (permalink / raw)



I noticed that "a-comlin.adb" is the only place in the Os2 version of
the GNATLIB library source code where "pragma Interface" is used
(according to a quick check with fgrep).

It struck me as odd, since in the one short section of code, there is
one "pragma Import", right next to two "pragma Interface"'s.

According to the Ada95 rational, "pragma Import" is to be preferred in
Ada95 over "pragma Interface" (obsoleted from Ada83 I believe).  I
think it did say that the two were functionally equivalent.

I'm curious as to why the pragma Interface's are used there.  Are they
a left over from a conversion from Ada83 code, or is there a positive
reason they're used?

I use the GNAT source code as a resource to remind myself of what good
Ada95 code looks like<g>. and this one has me puzzled.

-- 
{===----------------------------------------------------------------------===}
                    Steve Whalen     swhalen@netcom.com
{===----------------------------------------------------------------------===}




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GnatLib vs. pragma Interface
  1997-08-20  0:00 GnatLib vs. pragma Interface Steve Whalen
@ 1997-08-20  0:00 ` Robert Dewar
  1997-08-21  0:00   ` Steve Whalen
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Dewar @ 1997-08-20  0:00 UTC (permalink / raw)



Steve asks

<<I'm curious as to why the pragma Interface's are used there.  Are they
a left over from a conversion from Ada83 code, or is there a positive
reason they're used?

I use the GNAT source code as a resource to remind myself of what good
Ada95 code looks like<g>. and this one has me puzzled.>>

pragma Interface is not an official part of Ada 95, but in practice it
will be supported by any reasonable Ada 95 compiler (you can make sure
you avoid such uses if you like by using

  pragma Restrictions (Implementation_Pragmas)

(which unfortunately is not a standard feature ...)

<<According to the Ada95 rational, "pragma Import" is to be preferred in
 Ada95 over "pragma Interface" (obsoleted from Ada83 I believe).  I
 think it did say that the two were functionally equivalent.>>

If the Rationale says this, it is wrong. The Ada 83 pragma is definitely
NOT equivalent to the Ada 95 Import pragma (although in GNAT, Interface
is extended to be equivalent). And as noted above, Interface is NOT IN
Ada 95, so it is not just an obsolescent feature which someone thinks
is bad style to use, it is a potentially non-portable interface (not
that this is a consideration in the GNAT sources themselves).

The GNAT code should indeed use Import, and you may award yourself a prize
for finding a bug in the GNAT sources. If you send it off to report@gnat.com,
it will no doubt get fixed :-)

Of course this is not exactly the most critical bug located recently -- but
on the other hand, cleaning up the sources is a valuable long term goal!





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GnatLib vs. pragma Interface
  1997-08-20  0:00 ` Robert Dewar
@ 1997-08-21  0:00   ` Steve Whalen
  1997-08-21  0:00     ` Robert Dewar
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Whalen @ 1997-08-21  0:00 UTC (permalink / raw)



re: pragma Interface and the rationale saying pragma Import was
equivalent (and if the rationale said that, it was wrong):

Well, my memory isn't what it used to be. Part of what the rational
does say about pragma Interface / Import:

...

B.1  Interfacing Pragmas

Experience with pragma Interface in Ada 83 has uncovered a number of
issues that may interfere with developing portable Ada code that is to
be linked with foreign language modules.  We have therefore removed
pragma Interface (though the implementation may choose still to
support it for upward compatibility) and have added the three pragmas
Import (effectively replacing Interface), Export and Convention which
provide the following capabilities:

...

So I guess I was reading in / remembering more equivalence between
Interface and Import than is there. I agree that "effectively replace"
is not "equivalence", so the rationale is right.

Thanks for the clarification. I kind of thought the use of pragma
Interface in GNAT was an anachronism.  I hardly think of it as
much of a bug (more a potential future buglette!).  But I'll send
it off to the official bug list so it can be cleaned up some day.

-- 
{===----------------------------------------------------------------------===}
                    Steve Whalen     swhalen@netcom.com
{===----------------------------------------------------------------------===}




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GnatLib vs. pragma Interface
  1997-08-21  0:00   ` Steve Whalen
@ 1997-08-21  0:00     ` Robert Dewar
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1997-08-21  0:00 UTC (permalink / raw)



Steve said

<<Thanks for the clarification. I kind of thought the use of pragma
Interface in GNAT was an anachronism.  I hardly think of it as
much of a bug (more a potential future buglette!).  But I'll send
it off to the official bug list so it can be cleaned up some day.>>


It you are referring to the possibility that we might remove pragma
Interface one day, that is not a possibility -- pragma Interface is
there for compatibility with Ada 83, and this requirement (for
Ada 83 compatibility) will be around for a long long time!

GNAT implements *all* the Ada 83 pragmas and attributes, and is committed
to continuing to include this capability.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-08-21  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-08-20  0:00 GnatLib vs. pragma Interface Steve Whalen
1997-08-20  0:00 ` Robert Dewar
1997-08-21  0:00   ` Steve Whalen
1997-08-21  0:00     ` Robert Dewar

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