Il 21/02/22 00:10, Eric Bezault ha scritto:
On 20/02/2022 23:39, Paolo Redaelli wrote:
Wise words. I always wondered if "inherit {NONE}" is non conforming
inheritance, what's the meaning of "inherit {ANY}" or inherit
"{SOME_OTHER_CLASS}" ?
* inherit {NONE}: inheritance link (i.e. conformance) visible
by no class. No client knows that the current class inherits
from its parent, and therefore we cannot use this property
when trying to figure out whether the type of the source of an
assignment appearing in the client class conforms to the type
of the target.
* inherit {ANY}: inheritance link visible by all classes.
* inherit {SOME_OTHER_CLASS}: inheritance link visible only
by descendants of class SOME_OTHER_CLASS.
It's not very different from the notions 'feature {FOO}' or
'create {FOO}' where the feature or creation procedure is visible
only to descendants of class FOO, or to no class if FOO is NONE,
or to all classes if FOO is ANY.
That's interesting yet, but I can't find an use case....
For example...
class FOO feature salute do ... end
class HEIR inherit {FRIEND} FOO
class TRAITOR inherit {FOE} FOO
and somewhere else
class PERSON
feature manage(a_foo: FOO) a_foo.salute end
feature handle
local h: HEIR; t: TRAITOR
do
manage(h)
manage(t)
end