In message 4C6E5C32.20010308193203.FOO-4495.frank@g-n-u.de Frank Heckenbach writes:
Peter Gerwinski wrote:
Having now looked at an 'Object Pascal Language Guide' that came with a copy of Borland Delphi for Windows, I'm not convinced that class is being handled in the Delphi manner. This Guide says "Unlike other types, a class type can be declared only in a type declaration part in the outermost scope of a program or unit. Therefore, a class type can't be declared in a variable declaration part or within a procedure, function, or method block."
So an example similar to the example I posted last night:
program test_class(input,output);
type tcomp=packed record name:string[80]; class:1..15; end; var comp:tcomp;
begin end.
should fail.
However, I think the following example:
program test_class2(input,output);
procedure proc; type tcomp=packed record name:string[80]; class:1..15; end; var comp:tcomp;
begin end;
begin proc; end.
should compile (and it doesn't).
I think the "news" section of the first part of the manual should document the introduction of class as a conditionally reserved word.
For the moment Russ Whitaker's suggestion of {$define class thing} as a quick and dirty patch looks the easiest way for me to proceed with this upgrade.
The question is whether a separate switch, specifically for enabling/disabling keywords, makes sense.
[...] I mean something like `--disable-keyword="Class"'.
Perhaps accept a list of keywords, e.g. `--disable-keywords="class,object"'.
I like that scheme, since, as I posted earlier, I have source code which is such a collection of different dialects within single files that the dialect switches are no use to me.
On 8 Mar 01, at 19:47, David James wrote:
[...]
However, I think the following example:
program test_class2(input,output);
procedure proc; type tcomp=packed record name:string[80]; class:1..15; end; var comp:tcomp;
begin end;
begin proc; end.
should compile (and it doesn't).
Your code doesn't compile under any version of Delphi (from v1.0 to 5.0), therefore the GPC behaviour of rejecting it is correct. This is the typical output of the Delphi compilers;
Borland Delphi Version 12.0 Copyright (c) 1983,98 Inprise Corporation pp.pas(6) Error: 'END' expected but 'CLASS' found pp.pas(7) Error: ';' expected but 'END' found pp.pas(8) Error: Undeclared identifier: 'tcomp' pp.pas(11) Error: '.' expected but ';' found pp.pas(13) Error: Identifier redeclared: 'Finalization'
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) Author of: Chief's Installer Pro for Win32 http://www.bigfoot.com/~African_Chief/chief32.htm Email: African_Chief@bigfoot.com
David James wrote:
Having now looked at an 'Object Pascal Language Guide' that came with a copy of Borland Delphi for Windows, I'm not convinced that class is being handled in the Delphi manner. This Guide says "Unlike other types, a class type can be declared only in a type declaration part in the outermost scope of a program or unit. Therefore, a class type can't be declared in a variable declaration part or within a procedure, function, or method block."
So an example similar to the example I posted last night:
program test_class(input,output);
type tcomp=packed record name:string[80]; class:1..15; end; var comp:tcomp;
begin end.
should fail.
However, I think the following example:
program test_class2(input,output);
procedure proc; type tcomp=packed record name:string[80]; class:1..15; end; var comp:tcomp;
begin end;
begin proc; end.
should compile (and it doesn't).
I suppose that, while class declarations are allowed only globally in the outermost scope, `class' is a reserved word throughout. That's what the Chief said Delphi does, and what I know TP does with `object'.
We could try to make `class' conditionally reserved only in the outermost scope, but I don't know how hard this would be (Peter?), and it wouldn't solve the issue completely. So I think I'd prefer `disable-keyword' as well...
I think the "news" section of the first part of the manual should document the introduction of class as a conditionally reserved word.
I'm a little surprised. According my old copy of the 19990118 sources, `class' was already conditionally reserved there. But anywaym I will document it, as well as `attribute' and `published' which have become (conditional) keywords since that version AFAICT. If there are more keywords I should mention, let me know.
Frank
Frank Heckenbach wrote:
We could try to make `class' conditionally reserved only in the outermost scope, but I don't know how hard this would be (Peter?),
The problem is that the parser always reads one token in advance, so at the moment where it knows that the keyword must be disabled now, it might be read already.
and it wouldn't solve the issue completely. So I think I'd prefer `disable-keyword' as well...
I agree. I once hacked the `protected' keyword such that it can be used simultaneously with its meaning in Extended Pascal and as a new identifier:
procedure Foo (protected protected);
But this caused more confusion than good.
Peter
Peter Gerwinski wrote:
Frank Heckenbach wrote:
We could try to make `class' conditionally reserved only in the outermost scope, but I don't know how hard this would be (Peter?),
The problem is that the parser always reads one token in advance, so at the moment where it knows that the keyword must be disabled now, it might be read already.
For structured type declarations (like David's example), this would be a problem, I guess. For local scopes, it wouldn't...
[...] But this caused more confusion than good.
Exactly... ;-)
Frank