Hello folks,
(* This mail is somehow long. In short: I want to take the directives `Extern', `C', and `AsmName' *out* of GPC and extend the syntax of `External' instead. Okay? :*)
as you know (?;-), we have the directives `External', `Extern' (same as `External'), `C', and `AsmName' in GPC for specifying external procedures. This is especially useful when using libraries written in C, for example:
Procedure Foo; External; (* yields "Foo" *)
Procedure ioCtl ( FilDes, Cmd: Integer; ... ); C; (* yields "ioctl" *)
Procedure XOpenDisplay ( Name: __CString__ ); AsmName 'XOpenDisplay';
This turned out not to be enough; we need the same for variables. Actually we already have
Var Foo: __external__ Integer; (* yields "foo", not "Foo"! *)
but this does not cover cases where the external variable needs a name with a capital letter.
As an intermediate solution, I implemented
Var Foo: __asmname__ 'foO' Integer;
(patched source is available on demand), but I think it is not the best way to implement these things.
Now I am looking out for reasonable ideas.
Does somebody know what the ISO/ANSI Standards say about this?
My own thoughts follow.
I would suggest to define as few directives as possible and to drop everything but `External' but extend its syntax to meet our requirements. A first approach could be
Procedure foo; external; (* yields "Foo" *)
Var x: Integer; external; (* yields "X" *)
and
Procedure foo; external 'foO';
Var x: Integer; external 'my_x';
but it would crash with Borland Pascal's use of `External' where the latter declaration would mean that Procedure foo is contained in a shared library named `foO'.
Okay, so let's stay for the moment at Borland's syntax. In the same context they also define
Procedure foo; external 'MySharedLib' index 42;
and
Procedure foo; external 'MySharedLib' name 'foO';
where `foO' would be the external name as defined in the shared library.
My current idea now would be to define
Procedure foo; external; (* yields "Foo" *)
Var x: Integer; external; (* yields "X" *)
plus
Procedure foo; external name 'foO';
Var x: Integer; external name 'my_x';
to replace "AsmName 'foO'". Later we can extend this to allow a name of a shared library between `external' and `name'.
Once doing this, it could also be nice to make directives out of the other C-style storage qualifiers, too. I mean I'd like to replace
Var x: __static__ Integer; by x: Integer; static; y: __volatile__ Integer; by y: Integer; volatile;
etc.. My plan is to do it in a way that things like
Var static: Integer;
would still work.
I think it would *not* be a good idea to make
Procedure foO; external;
yield "foO", because (i) it would be difficult to implement and (ii) Pascal is a case-insensitive language, so everything outside string constants *must not* depend on casing at all.
Please tell me your opinion about this.
Yours,
Peter
e-mail: peter.gerwinski@uni-essen.de home address: D"usseldorfer Str. 35, 45145 Essen, Germany WWW: http://agnes.dida.physik.uni-essen.de/~peter
On Sat, 7 Sep 1996, Peter Gerwinski wrote:
Hello folks,
(* This mail is somehow long. In short: I want to take the directives `Extern', `C', and `AsmName' *out* of GPC and extend the syntax of `External' instead. Okay? :*) I would suggest to define as few directives as possible and to drop everything but `External' but extend its syntax to meet our requirements. A first approach could be
Good idea. Having 3 directives which basically do the same thing is pretty stupid.
My current idea now would be to define
Procedure foo; external; (* yields "Foo" *) Var x: Integer; external; (* yields "X" *)
plus
Procedure foo; external name 'foO'; Var x: Integer; external name 'my_x';
to replace "AsmName 'foO'". Later we can extend this to allow a name of a shared library between `external' and `name'.
No objections to this idea from me. Anybody else?
Hey ... did y'all know that a Linux version of FPKPascal (or is it just FPPascal??) is now out (currently only a.out but and ELF version is expected soon). One thing I like about FPKPascal is that it has function overloading. Any plans of adding this to GPC? This would be a nice thing to throw in, IMHO.
=============================================================================== Arcadio Alivio Sincero, Jr. Sophomore, Computer Science Major at the University of Maryland at College Park Amateur competitive bodybuilder Email: lotu@wam.umd.edu, WWW: <coming soon to a web site near you!>
"D.A.R.E. .... to keep cops off donuts."