Prof A Olowofoyeku (The African Chief) wrote:
On 11 Feb 2003 at 4:15, Frank Heckenbach wrote:
[...]
As the note in the GPC unit says:
: This unit contains Pascal declarations of many RTS routines which : are not built into the compiler and can be called from programs. : Don't copy the declarations from this unit into your programs, but : rather include this unit with a `uses' statement. The reason is : that the internal declarations, e.g. the `asmnames', may change, : and this unit will be changed accordingly.
If you just need some declarations from the GPC unit in your units, you might achieve it via `only' imports (see my other mail), possibly with import renaming to avoid name conflicts:
import GPC only (FileMode => GPC_FileMode);
If you also need to re-export some of those declarations, I'll have to think further ...
That is exactly the problem. As you remember, Delphi's Sysutils is a sort of amalgam of routines from the old BP Strings and Dos units - some are identically named, and some are not. Instead of reinventing the wheel, I just export them using the asmnames. If the asmnames will be changing frequently, this kind of solution becomes a non-starter.
Indeed.
Therefore I suggest that asmnames should not be changed until we have qualified identifiers.
I'm not sure if QI will be a really good solution, either. AFAICS, you'd then need wrapper functions in order to re-export the routines (which you currently don't need, provided the parameters etc. are exactly the same).
OTOH, modules allow for direct re-exporting, optionally with renaming. The following example works with the current GPC:
module Foo;
export Foo = (a, Bar, FileMode => GPC_FileMode);
import GPC;
var a: Integer = 42;
procedure Bar;
end;
procedure Bar; begin WriteLn ('bar') end;
to begin do WriteLn ('qwe');
end.
GPC allows for importing a module with `uses' or `import', just like units, so the user of the module should not notice any difference.
The backdraws (except the module syntax, and a few module bugs which will hopefully be fixed soon), is that you have to name all identifiers to be exported in the `export' clause. Often this will be all interface declarations which have to be repeated there.
GPC supports, as an extension `export Foo = all' which exports all interface declarations -- but only those, i.e., one can't add any re-exports or do any renaming.
But it should be possible with moderate effort to implement something like
export Foo = all (FileMode => GPC_FileMode);
so one won't have to name all interface declarations, but only the re-exports and renamings explicitly.
Frank