Bug? Delphi-style result variable
Waldek Hebisch
hebisch at math.uni.wroc.pl
Sat Mar 5 04:24:14 CET 2005
Frank Heckenbach wrote:
> Waldek Hebisch wrote:
> > BTW, I think that we should have a way to enable/disable all predefined
> > words. Personally I would call `Result' or `Dispose' a keyword
>
> I call keywords only those names that cannot be used as identifiers
> (in the respective dialect), i.e. what ISO calls word-symbols. Both
> `Result' and `Dispose' can be redefined in all dialects AFAIK.
>
If something can not be redefined, I call it a reserved word. But probably
for most Pascal users keyword = reserved word.
> > 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. Concerning other builtins: old programs
frequently are "almost" classic Pascal, with some extra builtins.
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.
But my main motivation is symmetry. I prefer one general-purpose
mechanizm then a bunch of special cases.
BTW. `--enable-builtin-identifier' may correspond better to your
intuition.
--
Waldek Hebisch
hebisch at math.uni.wroc.pl
More information about the Gpc
mailing list