On 19 May 2004 at 14:12, Frank Heckenbach wrote:
[...]
- Do you agree that if an object type `oo' has a parent type `o', and this parent has a method function `f', then in a method of `oo' the expression `o.f' is valid syntax for a call of that former method function?
Yes.
- Do you agree that if an object type has a field `o' which is a record which has a field `f' than within a method of this object type `o.f' is valid syntax to access this field?
Yes.
- Do you agree that the preconditions of both 1. and 2. are fulfilled in my original program?
Yes.
- If so, I suppose you'll agree that `o.f' in `oo.p' is valid syntax for both the parent method call and the subfield access.
Yes.
That's what an ambiguity is.
Perhaps, even though it seems pretty obvious to me that it is the record field of the oo object that is in scope ....
- The fact that both BP and GPC so far choose one of the interpretations (namely 2.) does not mean that there is no ambiguity, just that it's resolved arbitrarily.
I wouldn't call it arbitrary. I would just say that it's a question of scope. However, I wouldn't press the issue either.
IAC, if one person sees something as ambiguous, then it is ambiguous, and so perhaps code like that should generate at least a warning (except in BP/Delphi mode). For my part, I would just leave it as it is.
Well, in fact, if it's ambiguous, the warning should be there even in BP mode (as we warn for other dangerous features), while elsewhere it may well be an error. (Since the declarations of the two `o's and `f's can be far apart in the program, it might not be easy for a programmer to notice such a problem if he ever runs into it, and he might be very confused by the field access if he's trying to call the parent method and unaware of the field name conflict. That's why I consider it a bit dangerous. BTW, I don't suppose Borland made it so intentionally -- perhaps they just overlooked this potential problem.)
BTW, I don't think many real programs would run into this problem, because object type names and field names are usually quite different. Therefore I'd almost like to forbid it entirely, but for compatibility's sake, I'll go with a warning in BP mode.
A warning it is then!
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.greatchief.plus.com/