At 2:36 PM +0100 25/2/03, Frank Heckenbach wrote:
GPC supports a number of keywords that do not belong to all (or any ;-) known Pascal standards/dialects. To relieve the resulting problems, there are currently 3 mechanisms:
If any dialect option (`--extended-pascal' etc.) is used, all keywords not belonging to this standard are deactivated completely.
Individual keywords can be disabled using `--disable-keyword'.
Some keywords are recognized only depending on context, so compiling a program that uses them as identifiers is still possible without any of the above options.
However, the 3rd approach only works in some situations (and can never work perfectly, since at some points there would simply be syntactic ambiguities between certain keywords and identifiers).
While it (probably!) won't affect me, I prefer that people use the second to make an explicit statement about what they are trying to achieve, although it'd be nice to have it as a compiler directive so that it can be placed within the source as so to make the source self-documenting in this respect, e.g.
{$pascal-dialect extended-pascal}
{$disable-keyword operator}
While others might argue that this is not portable, at least it reminds you what you intended! (The disadvantage is that it'd need to be in every source file and you might get issues if the dialect started differing in the different source files!)
I think the whole idea of interpreting the meaning of an identifier in context is a shade dodgy (see my other post today mentioning simple rules for determining user identifier and predefined keyword conflicts). Although clunky in many ways, I thought one of the original things in Pascal was that keywords just were keywords, no matter where they were found. Magically switching off a keyword in a given context seems confusing. This is why I suggested the use of quotes in the external case (to make the keywords explicitly reduced to the scope of the quote).
That said, there must be pragmatic cases where it'd be nice to avoid conflicts in legacy code (like mine! :-) ). Perhaps this should of thing by default should _not_ take place unless the user explicitly asks for it to happen to specific identifiers, e.g.
{$allow-user-identifier static}
(Note this doesn't disable the keyword)
and/or
{$context-dependent static}
for the really sticky cases only (and only if anyone ever implements it!).
I think for some words it would be easier to recognize them as keywords only if they have no current meaning (as identifiers) in the program, rather than turning them on and off in certain syntactic places (which is quite error-prone and probably still has some subtle bugs). I'm not sure if this approach will work for all problematic keywords, but at least for some.
So this will still work:
program Foo;
var Foo: static Integer;
begin end.
Also this:
program Foo;
procedure Bar; var Static: Integer; begin end;
var Foo: static Integer;
begin end.
But not this (which works now):
program Foo;
var Static: Integer; Foo: static Integer;
begin end.
Do you think this would a problem? It should not affect the ability to compile, say, EP code without `--extended-pascal' *as far as* that's possible now, since EP code can't use `static' as a directive (and it can't use as identifiers what are keywords in EP).
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: 51FF C1F0 1A77 C6C2 4482 4DDC 117A 9773 7F88 1707