On Tuesday, April 9, 2019 at 8:32:25 PM UTC-7, Ashok wrote:
> That code generating the error is not actually in the book is it? It
> would need to be added to the errata if it is but I couldn't locate it
> in the book.
>
Sorry I posted my own simpler example, however, I did initially try
one from the book,
section 14.2.4 Defining methods, the example
oo::define Account {
method UpdateBalance {change} {
set Balance [+ $Balance $change]
return $Balance
}
method balance {} { return $Balance }
method withdraw {amount} {
return [my UpdateBalance -$amount]
}
method deposit {amount} {
return [my UpdateBalance $amount]
}
}
And it gets the error,
> In any case, to answer your question,
> constructor {} {
> namespace path [linsert [namespace path] 0 ::tcl::mathop]
> }
But this does indeed do the job. I don't think you mention needing
this in the book, at least not along with your example above. And
constructors are later in the book, 14.2.5. I used them with the
above code.
So, from what I can see I can get away with just the one global
level namespace command for all proc's (in same interpreter I imagine)
but for objects, one needs one per class definition.
Thanks.
BTW, hope your next book is on TK and especially the ttk themes.
I use pdf-xchange viewer, a free portable pdf reader. Being searchable
and able to copy/paste for testing is a great resource.
The 1 sided pdf displays great with toc on left, search on right.