Re: Invisible variable problem in itcl inheritance
From: Geoff Battye (geoff_at_mrc-lmb.cam.ac.uk)
Date: 02/16/04
- Next message: Jos Decoster: "http::geturl in starkit/starpack"
- Previous message: Bruce Hartweg: "Re: Concurrency (Connected to "Starting Again...")"
- In reply to: Ding: "Invisible variable problem in itcl inheritance"
- Next in thread: Daniel: "Re: Invisible variable problem in itcl inheritance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 16 Feb 2004 14:50:24 +0000 To: Ding <dinghs@hotmail.com>
Ding,
I'm not an expert, but as no-one else has answered yet, I'll have a go:
The problem is not that you cannot 'see' the inherited member variable
'content' from inside class c. It is clear that 'content' does indeed hold
the name of the object of class a, as the error message even reports it
(a0).
The problem is that 'content' holds the name of the object created within
the scope of class b, but you are trying to use it in the scope of
class c.
One solution to the problem that you have already worked out is to
explicitly provide the correct qualifier when accessing content (i.e.
b::$content, as used in doIt1). An alternative solution would be to store
the fully qualified name directly in the member variable 'content'. To do
this change the body of class b's gen method to:
set content [namepsace current]::[a #auto]
If you make this change, then class c's method 'doIt3' will work. Note,
however, that this change will break class c's method 'doIt1', as you will
be trying to call the function 'b::::b::a1'. You can either record the
scope in the variabel 'content' or add the scope when accessing 'content',
but not both!
Hope this helps,
Geoff.
- Next message: Jos Decoster: "http::geturl in starkit/starpack"
- Previous message: Bruce Hartweg: "Re: Concurrency (Connected to "Starting Again...")"
- In reply to: Ding: "Invisible variable problem in itcl inheritance"
- Next in thread: Daniel: "Re: Invisible variable problem in itcl inheritance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]