On 25 Feb 2003 at 14:47, Frank Heckenbach wrote:
As another small step towards cleaning up the `external' mess in GPC, I'm now implementing `external name', i.e.
procedure Foo; external name 'bar';
[...]
But there are cases where you need to set the asmname of a non-external routine or variable. But perhaps we can just use `name' then, e.g.:
var Foo: Integer; name 'bar';
That is orthogonal with the above usage and so is less confusing than:
var Foo: Integer; attribute (name ('foo'));
There is nothing inherently wrong with using "attribute." However, there is a lack of symmetry between:
var Foo: Integer; external; name 'bar'; { external variable }
and:
var Foo: Integer; attribute (name ('foo')); { global variable }
It would seem to be desirable to have global and external entity names specified with similar syntax. So I would suggest either specifying both with "name" or both with "attribute" but not a mix of the two.
I don't know enough Fortran or Ada to tell if there are such mechanisms...
In Ada, both imports of external entities and exports of global entities are specified via the "pragma" compiler directive:
Foo : Integer; pragma Import (C, Foo, "foo");
or:
Foo : Integer; pragma Export (C, Foo, "foo");
...where the first parameter is the interfacing convention, the second is the Ada name of the affected entity, and the third is the name as viewed from the target interface. So the proposed "attribute" syntax is actually quite close to this, e.g.:
Foo : Integer; pragma Import (C, Foo, "foo"); -- Ada
...would be equivalent to:
var Foo: Integer; external; attribute (name = 'foo'); { Pascal }
The full Ada syntax is:
pragma Import( [Convention =>] convention_identifier, [Entity =>] local_name [, [External_Name =>] string_expression] [, [Link_Name =>] string_expression]);
pragma Export( [Convention =>] convention_identifier, [Entity =>] local_name [, [External_Name =>] string_expression] [, [Link_Name =>] string_expression]);
-- Dave