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
participants (2)
-
Arcadio Alivio Sincero -
Peter Gerwinski