[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: trouble with bind
I did resolve the trouble I had with bind, but forgot to post the
explanation (see the original posting below).
In summary:
If a C++ object's constructor performs a "bind" operation,
then the constructor should be invoked by a "new" in the tcl code,
not a "new" in C++ code. This is necessary, due to the way tcl state
is maintained in NS.
In my example below an object of type NewClass was, in fact, being
created in the tcl code. However, its C++ constructor does
"new DropTail". The constructor for DropTail performs a bind
for variable drop_fron_ - this is illegal (or unsupported).
Reason: At this point, the tcl state is only aware that we
are performing "new NewClass" (by inheritence, it is also aware
of all the superclasses of NewClass). However, it is not aware that
NewClass *contains* a DropTail object. Thus, tcl bind looks for
drop-front_ definition in NewDrop, does not find one, and results
in an error message.
My quick-fix to this was to get rid of the drop_front_ variable
from DropTail class.
A better solution would be to to call tcl procedures
to create DropTail members of NewClass.
- nitin
>> At 04:16 PM 8/14/98 -0700, Nitin Vaidya wrote:
>> >
>> >
>> >I seem to have come across a feature/bug in bind, perhaps due to misuse
>> >on my part.
>> >
>> >
>> >Here is my scenario:
>> >
>> > DropTail::DropTail() {
>> > ...
>> > bind("drop-front_", &drop_front_);
>> > ...
>> > }
>> >
>> >
>> > NewClass::NewClass() {
>> >
>> > DropTail *Q = new DropTail;
>> >
>> > } new_class ;
>> >
>> >
>> > When the constructor for "new_class" is executed, I get the
>> > run-time warning
>> >
>> > warning: no class variable NewClass::drop-front_
>> >
>> > Why does this warning appear?
>> > The warning is issued when executing the "bind" when the constructor
>> > for object Q (class DropTail) is executed.
>> > If the constructor is for DropTail class, why does the Warning refer to
>> > class NewClass ?
>> > NewClass does not declare or use drop-front_ anywhere.
>> >
>> > Any clarification would be appreciated.
>> >
>> > Regards.
>> >
>> > - nitin
>> >
>> >
>> >