|
From: Will D. <wi...@wj...> - 2008-06-15 14:13:23
|
On Jun 15, 2008, at 5:43 AM, Donal K. Fellows wrote:
> Arnulf Wiedemann wrote:
>> That looks ok for itcl as far as I can see at the moment. Will
>> method speak2
>> work as I have written it (see below)?
>
> Yes.
In Donal's example, we have an instance variable, utterance, declared
for the "animal" class; the variable is visible without declaration in
subclass "cat"'s methods, e.g., "speak2".
This strikes me as dangerous; a new instance variable added to an
ancestor class that has the same name as a local variable used in a
subclass method can break the subclass method.
Donal, in your example, "dog" declares utterance explicitly; does that
make any difference? Given that method "cat"'s "speak2" can see
utterance, it would appear not.
Will
------------------------------------------------------------------
will -at- wjduquette.com | Catch our weblog,
http://foothills.wjduquette.com/blog | The View from the Foothills
|