deferred class
MY_CLASS_1
feature
make
do
value := "1"
end
value:STRING
end
deferred class
MY_CLASS_2
inherit
MY_CLASS_1
redefine
make
end
feature
make
do
value := "2"
end
end
class
MY_CLASS_3
inherit
MY_CLASS_1
rename
value as value_1,
make as make_1
select
value_1,
make_1
end
MY_CLASS_2
rename
value as value_2,
make as make_2
end
create
make
feature {NONE} -- Initialization
make
-- Initialization of Current
do
make_1
make_2
end
end
make_2
-- (from MY_CLASS_2)
do
value_1 := "2"
end
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
'Louis M' via Eiffel Users <eiffel...@googlegroups.com>:
MY_CLASS_1
rename
value as value_1,
make as make_1
select
value_1,
make_1
end
MY_CLASS_2 -- (A)
rename
value as value_2,
make as make_3
end
MY_CLASS_2 -- (B)
rename
value as value_3,
make as make_2
end
--
Hi Louis,
Sorry to be a little harsh, but "replicating inheritance" is IMHO
a broken concept that should not be used. Replicating inheritance
always happens when you have a single parent concept multiple
times in the same class. In Eiffel, it is very simple to detect,
as it forces you to use the 'select' keyword.
In this case, 'value' and 'make' are declared in MY_CLASS_1, but
then in MY_CLASS_3 you have two of each. As you have correctly
observed, the polymorphic binding within each method is
non-intuitive. Alexander has given a good description of what
actually happens.
In theory, replicated inheritance can be a language feature, but
that would require a much more complicated way of polymorphic
binding, and that is probably not worth it. Non-polymorphic
inheritance might be another way to deal with it.
In every serious code base that I have seen in Eiffel, the use of 'select' was a code smell, mean that the developer used inheritance where actually some kind of aggregation was more appropriate.
Regards,
Bernd
PS: A classic example for replicating inheritance is that a
two-dim ARRAY2 inherits from ARRAY twice, once for the horizontal,
once for the vertical direction. This is a nice idea, but just not
implementable in Eiffel. Eiffel misses language features to
support this.
class
MY_CLASS_3
feature {NONE}
my_thing_1: MY_CLASS_1
my_thing_2: MY_CLASS_2
-------- Original Message --------
Subject: [eiffel-users] Re: Repeated inheritance
From: "'Louis M' via Eiffel Users" <eiffel...@googlegroups.com>
Date: Tue, May 22, 2018 3:51 pm
To: Eiffel Users <eiffel...@googlegroups.com>
--