| I actually think that your existing convention (1st upper, rest | lower) is an excellent way to resolve most things. I am quite sure | I don't have a grasp of the conflicting systematic
I also don't understand the conflicts, but this rule is painful. If I name a variable 'something' then I expect to be able to search the error messages for 'something' but of course it got changed to 'Something'. So if I want to cut and paste to search for the name in my program, it fails.
Why not take the first occurence of a variable as the name to use on all output? Then internally have a table (as others have suggested) mapping the first occurence to the actual one. Flag variables that map to the same word but which are not the same. This way the compiler merely demands consistency, but is 'case insensitive'.
Note: only Germans like to capitalize all nouns!
Tom
Dr. Thomas D. Schneider National Cancer Institute Laboratory of Experimental and Computational Biology Frederick, Maryland 21702-1201 toms@ncifcrf.gov permanent email: toms@alum.mit.edu (use only if first address fails) http://www.lecb.ncifcrf.gov/~toms/
Tom Schneider wrote:
| I actually think that your existing convention (1st upper, rest | lower) is an excellent way to resolve most things. I am quite sure | I don't have a grasp of the conflicting systematic
I also don't understand the conflicts, but this rule is painful. If I name a variable 'something' then I expect to be able to search the error messages for 'something' but of course it got changed to 'Something'. So if I want to cut and paste to search for the name in my program, it fails.
I didn't like this as well, and that's exactly why I've brought up the issue.
Why not take the first occurence of a variable as the name to use on all output?
The first, or the most recent one, that's still a question. After some experimenting, there seem to be points for both ways. I'm implementing the latter now (though it should be easy to change). So, e.g.:
program Baz;
procedure Foo; var BaR: Integer; begin end;
begin WriteLn (bar) end.
will complain about an unknown identifier `bar', not `BaR' ...
Note: only Germans like to capitalize all nouns!
I know, and that's not the reason why this rule was introduced (long ago). Rather it was to avoid asmname conflicts with libc routines etc. -- see, e.g., Pierre's mail for detailed explanations.
Frank
Frank Heckenbach wrote:
Why not take the first occurence of a variable as the name to use on all output?
The first, or the most recent one, that's still a question. After some experimenting, there seem to be points for both ways. I'm implementing the latter now (though it should be easy to change). So, e.g.:
program Baz;
procedure Foo; var BaR: Integer; begin end;
begin WriteLn (bar) end.
will complain about an unknown identifier `bar', not `BaR' ...
That's quite natural, since the line in the main program _is_ the first occurence of `bar'. Outside procedure Foo, BaR isn't known at all.
But what about this case?
Program Baz;
Procedure Foo ( Bar: integer ); begin end;
begin foo; end.
... would complain about a missing parameter calling procedure `foo' in line 8. However, I'd rather talk about procedure `Foo' here, since this one's the line to look up in the source in order to get the correct routine's parameter list. (The line where the error occurred is already denoted in the error message: line 8.)
I'd generelly prefer to use the spelling of the _declaration_ of an identifier, not the spelling of a usage somewhere in the source. Which means: In your example, the error message still complains about an unknown identifier `bar' (since it's never declared in the context where it was used), but in my example we would get a message about incorrect use of `Foo' (spelling of the declaration).
Just one more example to complete the confusion:
Program Baz;
Procedure Foo; var bAR: integer; begin end;
Procedure BaR ( foo: integer ); begin end;
begin bar; end.
This one would, in my convention, complain about a missing parameter when calling procedure `BaR' (declaration), though this is neither the spelling of the first occurrence (local var), nor of the last occurrence (call). But I'd prefer the compiler to run like this, since it leads exactly to the right line when looking it up with a case-sensitive text search.
Yours,
Markus
On Sat, Jan 11, 2003 at 11:40:23PM +0100, Frank Heckenbach wrote:
I wrote:
- Default? (I suppose off, though I think I myself would prefer on.)
There have been some votes for both sides. So, would anyone object if off is the default, and `-Wall' implies on? (Those who want the other `-Wall' warnings except this one can use `-Wall -Wno-identifier-case' then.)
I agree, this seems reasonable.
On Tue, Jan 14, 2003 at 11:13:57AM +0100, Markus Gerwinski wrote:
Frank Heckenbach wrote:
Why not take the first occurence of a variable as the name to use on all output?
The first, or the most recent one, that's still a question. After some experimenting, there seem to be points for both ways. I'm implementing the latter now (though it should be easy to change). So, e.g.:
program Baz;
procedure Foo; var BaR: Integer; begin end;
begin WriteLn (bar) end.
will complain about an unknown identifier `bar', not `BaR' ...
That's quite natural, since the line in the main program _is_ the first occurence of `bar'. Outside procedure Foo, BaR isn't known at all.
You're right, IMHO. As a related question, it would seem unfortunate to me if -Widentifier-case enforced the same spelling to identifiers in different scopes.
Emil
Markus Gerwinski wrote:
Frank Heckenbach wrote:
The first, or the most recent one, that's still a question. After some experimenting, there seem to be points for both ways. I'm implementing the latter now (though it should be easy to change). So, e.g.:
program Baz;
procedure Foo; var BaR: Integer; begin end;
begin WriteLn (bar) end.
will complain about an unknown identifier `bar', not `BaR' ...
That's quite natural, since the line in the main program _is_ the first occurence of `bar'.
No, it's the second occurrence of the *identifier* `bar' (with any case).
Outside procedure Foo, BaR isn't known at all.
As a declaration.
But what about this case?
Program Baz;
Procedure Foo ( Bar: integer ); begin end;
begin foo; end.
... would complain about a missing parameter calling procedure `foo' in line 8. However, I'd rather talk about procedure `Foo' here, since this one's the line to look up in the source in order to get the correct routine's parameter list. (The line where the error occurred is already denoted in the error message: line 8.)
Of course, with `-Widentifier-case', you'd get the line number with the case warning.
But perhaps it's more useful to output the position of the declaration with the error message (which I'm doing now). Then you don't have to search anything, and it works also if it's in a different file.
I'd generelly prefer to use the spelling of the _declaration_ of an identifier, not the spelling of a usage somewhere in the source.
I thought about this, but at a quick glance that's much more work. I think one would have to check all usages of a declaration, while identifier case can easily be checked during lexing. For my purposes, it doesn't seem worth the effort (since I myself prefer to use uniform casing of identifiers throughout), but of course, you're free to implement it yourself ...
But I'd prefer the compiler to run like this, since it leads exactly to the right line when looking it up with a case-sensitive text search.
Of course, there's no reason to do a case-sensitive search in Pascal code. ;-)
Frank