Waldek Hebisch wrote:
but I would also agree to something like `--enable-predefined-identifier Result'.
We could probably do this rather easily (since we have the mechanism working for keywords already, and keywords and predefined-identifiers are handled rather similarly internally).
However, `Result' exactly is *not* a predefined identifier like the rest (that just why it's so evil).
In particular, we can't keep the current handling of `Result' (like a predefined identifier) in order to be Delphi compatible. The original problem Markus reported could be fixed with some additional code, but my example could not (unless adding really messy code, looking at scopes, searching for declarations called `Result', etc.).
So AFAICS the right thing to do for a Delphi compatible `Result' is to actually make it a local variable declaration (as we do for explicit result variables). This should be rather easy and will naturally handle scopes correctly.
Therefore, I think we need a separate option for `Result' anyway (independent of whether we decide to add `--enable-predefined-identifier' for other reasons -- I currently don't see a need for it, since predefined identifiers can be overriden easily, without the problems we have with `Result', but I may be convinced otherwise).
I agree that implementarion for `Result' is different. But from user point of view it is just attaching builtin meaning to a word, the same as other builtins.
Well, it's not the same, as it can shadow an explicit declaration, and can be shadowed by local declarations, and can shadow each other in nested functions. That's just the trouble we're discussing, of course. So I think it would only confuse users as well as it did us, if we pretended `Result' was like the other builtin identifiers.
Concerning other builtins: old programs frequently are "almost" classic Pascal, with some extra builtins.
If it's almost EP, I'd suggest making the extra stuff available through a module not compiled in EP mode. But in CP we don't have this option ...
Even with weak identifiers the easiest method to compile them may be to choose classic Pascal mode. But then only few builtins are available. So I think that ability to selectivly turn _on_ builtins is usefull. Similarly when there is "near miss" in dialect setting. Disabling builtins may be of some use to enforce coding guidelines.
That's a point.
But my main motivation is symmetry. I prefer one general-purpose mechanizm then a bunch of special cases.
I'm not talking about a "bunch" of special cases. `Result' is really different. All the other predefined ("level 0") identifiers are the same in this regard.
Prof A Olowofoyeku (The African Chief) wrote:
On 6 Mar 2005 at 8:20, Frank Heckenbach wrote:
[...]
I suggested `--enable-result', but as it may confuse someone not familiar with this problem, perhaps rather `--enable-implicit-result' (to be more explicit ;-).
That is fine. If it were my decision however, I would simply generate a warning whenever a global variable "Result" is defined. That should warn whoever is porting legacy code about potential problems, and once he/she has ensured that there are no problems, then he/she can disable the warnings.
Perhaps if everybody wanted to port their code to the Delphi dialect. But default warnings would also appear for people who have no intention doing so (including myself ;-), and who wouldn't agree to calling their code "legacy", BTW.
But AFAICS, the people who are porting legacy code to GPC are the ones we are worried about (because the original writers of the code did not know anything about "Result").
I'm not sure what you mean here. If you mean that code using `Result' as a regular identifier is "legacy" and should be changed, I disagreee.
CBFalconer wrote:
"Prof A Olowofoyeku (The African Chief)" wrote:
On 6 Mar 2005 at 8:20, Frank Heckenbach wrote:
... snip ...
IMHO it would be better to convice Borland to add explicit result variables (probably very easy to do for them) and add a warning for all that legacy code that uses implicit `Result', so one can change it, and they can finally disable it sometime. :-)
I just saw a pig flying past my window ... ;)
As someones sig says in some newsgroup "Given sufficient thrust, pigs fly very well."
RFC 1925
Frank