This site contains older material on Eiffel. For the main Eiffel page, see http://www.eiffel.com.

NICE Language Committee: name-clashes

From swissoft.h.provi.de!eiffel@Hannover.POP.DE Thu Oct  5 10:19:37 1995
Date: 05 Oct 1995 14:45:00 +0200
To: bertrand@eiffel.com
Cc: tynor@atlanta.twr.com
Subject: A question about VRFA and VRLE
X-Mailer: XP v3.02 R/C4131
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Content-Length: 1079
Status: RO
X-Lines: 25

Dear Bertrand, dear Steve,

I have a question about VRFA and VRLE. They say that a formal
argument or a local entity of a routine r in class C may not
have the same name as a feature of C. My question is: Does
this only apply to routines which have a declaration in class
C or does it also apply to routines which are inherited but
not redeclared. Suppose C inherits a routine r from P1 and
r has a local entity named e. Assume further that C inherits
a feature e from some other parent P2. If VRLE extends to
inherited routines, this would be invalid. If you don't
have access to the source code of P1, you cannot fix the
problem by choosing a different name for the local entity.
So you're forced to rename the feature e inherited from P2.
This is strange because we would have here a name clash
between a feature of one class and a local entity of a
feature of some other class. What are your opinions?

Best regards,
    Michael


SwisSoft, Michael Schweitzer      Geismar Landstr. 16  D-37083 Goettingen
Fax : +49 551 770 35 44           email : eiffel@swissoft.h.provi.de


From swissoft.h.provi.de!eiffel@Hannover.POP.DE Fri Oct  6 10:40:09 1995
Date: 06 Oct 1995 18:27:00 +0200
To: bertrand@eiffel.com
Cc: tynor@atlanta.twr.com
Subject: Re: A question about VRFA and VRLE
X-Mailer: XP v3.02 R/C4131
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Content-Length: 1022
Status: RO
X-Lines: 35

Dear Steve, dear Bertrand,

I'm not sure whether you've (Steve) really understood what I meant
which is probably entirely my fault. The problem is with multiple
inheritance: in a class C you inherit from two different parents P1 and
P2. They have routines 'r1' and 'r2' respectively. Now assume that
we have:

in P1:
                r1 is
                  local
                        r2 : SOMETHING
                   do
                    ...
                   end

in P2:
                r2 is
                  local
                        r1 : SOMETHING_ELSE
                  do
                   ...
                  end

So, by inheritance, 'C' has a routine 'r1' and a routine 'r2' and
VRLE says (or: that's really my question) that in C both 'r1'
and 'r2' are invalid.

Steve and Bertrand, does your compiler really check this?

Best regards,
        Michael
SwisSoft, Michael Schweitzer      Geismar Landstr. 16  D-37083 Goettingen
Fax : +49 551 770 35 44           email : eiffel@swissoft.h.provi.de


From tynor@atlanta.twr.com Fri Oct  6 12:19:21 1995
Date: Fri, 6 Oct 95 14:19:14 EDT
To: eiffel@swissoft.h.provi.de (Michael Schweitzer)
Subject: Re: A question about VRFA and VRLE
References: <9510061244.AA08071@atlanta.twr.com>
	<5vKFcQ1zLdB@swissoft.h.provi.de>
Cc: bertrand@eiffel.com (Bertrand Meyer)
Content-Length: 1540
Status: RO
X-Lines: 55

| I'm not sure whether you've (Steve) really understood what I meant
| which is probably entirely my fault. The problem is with multiple

Or my laziness...

| inheritance: in a class C you inherit from two different parents P1 and
| P2. They have routines 'r1' and 'r2' respectively. Now assume that
| we have:
|
| in P1:
|                 r1 is
|                   local
|                         r2 : SOMETHING
|                    do
|                     ...
|                    end
|
| in P2:
|                 r2 is
|                   local
|                         r1 : SOMETHING_ELSE
|                   do
|                    ...
|                   end
|
| So, by inheritance, 'C' has a routine 'r1' and a routine 'r2' and
| VRLE says (or: that's really my question) that in C both 'r1'
| and 'r2' are invalid.
|
| Steve and Bertrand, does your compiler really check this?

No.  But you could have introduced a similar violation without multiple
inheritence at all. Consider:

	class FOO
	feature
	  f is
	     local
	       g : ANY
	     ....


	class BAR
	inherit FOO
	   rename f as g
	end

Same `problem'.  Our implementation only checks the locals and routine
args of locally introduced features. Inherited bodies are presumed to be
OK (or more precicely, to not matter). So neither your and my example
would be flagged as a VRLE violation. If, on the other hand, I'd created
a class C by inherited P1 and P2 and tried to create an `r3' which had a
local named `r1' or `r2', then I _would_ get an error.

Steve

From tynor@atlanta.twr.com Fri Oct  6 06:38:01 1995
Date: Fri, 6 Oct 95 08:44:33 EDT
To: eiffel@swissoft.h.provi.de (Michael Schweitzer)
Subject: re: A question about VRFA and VRLE
References: <5vGFNXWzLdB@swissoft.h.provi.de>
Cc: bertrand@eiffel.com (Bertrand Meyer)
Content-Length: 801
Status: RO
X-Lines: 19

| I have a question about VRFA and VRLE. They say that a formal
| argument or a local entity of a routine r in class C may not
| have the same name as a feature of C. My question is: Does
....
| This is strange because we would have here a name clash
| between a feature of one class and a local entity of a
| feature of some other class. What are your opinions?

TowerEiffel uses the "flattened" set of names when checking VRLE and
VRFA.

I can see the benefit to limiting the search to the local features and
wouldn't have an objection to changing the language thusly, but for now,
that's how we're handling it. (actually, I wouldn't really have an
objection to removing the naming restriction altogether and allowing
locals and formal args to have the same name as features at class
scope).

Steve