Waldek Hebisch wrote:
Prof A Olowofoyeku wrote:
On 4 Mar 2005 at 6:49, Frank Heckenbach wrote:
... snip ...
it can in fact alter the behaviour of the same program in an incompatible way, as this example shows.
Yes, it possibly can. However, that outcome is fully understood (and expected) by Delphi programmers. Indeed, I have never heard of it being an issue, except perhaps in a contrived situation like this.
This makes it a really evil feature ...
I disagree. Any feature can be misused by careless programming. To me, it is not much different from;
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".
... 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. 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. 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.).
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.
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.