Prof A Olowofoyeku wrote:
On 4 Mar 2005 at 6:49, Frank Heckenbach wrote:
So, apparently, `Result' is not just another predefined identifier of a dialect like so many others. Because it's not defined at the outermost scope, but implicitly in each function,
Yes.
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.
I think it is pointless to discuss merits of the `Result' variable in itself. We _want_ to support `Result' variable for Delphi programs. And we want to correctly compile standard Pascal programs. So `Result' variable _is_ evil because we can not do those two things simultaneously (without a version switch). Note that unlike constructs which are illegal in one dialect but meaningfull in another this one can silently introduce bugs.
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'.