CBFalconer wrote:
There is one fundamental difference: take a classic Pascal program writen 15 years ago. The programmer had no way of knowing about Delphi `Result'. Since `Result' is a nice word there is quite good chance to find variables named `Result' in such a program. Once the program is big enough you will find assignment to outer `Result' in nested functions. Compile the program using Delphi (or Delphi mode of GPC). The program will compile, but silently produce wrong results.
The usage also violates the fundamental Pascal principal of "declare before use".
Actually it violates the principle of "declare" at all. That's the main problem.
... snip ...
BTW, I think that we should have a way to enable/disable all predefined words. Personally I would call `Result' or `Dispose' a keyword but I would also agree to something like `--enable-predefined-identifier Result'.
Dispose is in the class of standard procedures, declared in what I term the 'enclosing' or level 0 block. Result is an orphan. Nothing you do is going to meet all the previous usages.
Yes, that's why a compiler option is the best we can expect to meet everyone's needs.
For example, a forward declared procedure must have the actual procedure heading either identical or without parameters. I prefer identical, because you can then see the header when coding it.
So do I, and apparently many of us.
To use result sanely, it has to be declared in the function header, but it really only affects the implementation, so it shouldn't be in the forward declaration (or equivalent for modules/units etc.).
Now you're talking about explicit result variables. In fact, Markus's original posting was about these, and we've decided to allow omitting them in the forward declaration since, as you also say, they really only affect the implementation.
PascalP had the ability to enable/disable all non-standard Standard Procedures bodily. Now there are several classifications: the ISO7185 list, the ISO10206 list, the GPC list, the Turbo list, the Delphi list, and I suspect the classifications are not orthagonal. Those worms are squirming.
That's basically what we deal with with our dialect options, e.g. `--classic-pascal' disables all non-ISO7185 things. Most of the time they're only about disabling things, or changing semantics explicitly (`mod', field-widths, `-' precedence). But for `Result' we have to let a dialect option *enable* it.
Since they are declared at level 0 the only purpose in disabling them is to uncover non-portabilities in source code. There is no penalty whatsoever in redefining them at any level.
For such "level 0" things, yes. But each dialects also adds some new keywords, and for them, disabling them might be necessary to compiler other dialects' programs.
Frank