tcl oo superclass does not get created when there is no "next" statement in the constructor

Showing 1-6 of 6 messages
tcl oo superclass does not get created when there is no "next" statement in the constructor tombert 4/16/13 8:15 AM
Considering this example here:

oo::class create B {
   variable bvar
   constructor args {set bvar "fromB"}
   method getBvar args {return $bvar}
}

oo::class create A {
   superclass B
   variable avar
   constructor args {set avar "fromA"}
   method getAvar args {return $avar}
}

Without putting the "next" statement into the constructor of A it is impossible to call methods from class B:

> set a [A new]
::oo::Obj92
> $a getAvar
fromA
> $a getBvar
invalid command name "getBvar"

The help says: "Within the constructor, the next command should be used ..."
Either the help should say "... must be used ..." or this is a bug.

thx

Re: tcl oo superclass does not get created when there is no "next" statement in the constructor Donal K. Fellows 4/17/13 5:21 AM
On 16/04/2013 16:15, tombert wrote:
> The help says: "Within the constructor, the next command should be used ..."
> Either the help should say "... must be used ..." or this is a bug.

I've come across (rare!) cases where preventing the parent constructor
from running is desired. There are also cases for using [nextto] instead
of [next] (e.g., control over diamond inheritance).

Donal.
--
Donal Fellows — Tcl user, Tcl maintainer, TIP editor.
Re: tcl oo superclass does not get created when there is no "next" statement in the constructor tombert 4/22/13 2:11 AM
Ok - so it is better to leave it to "... should be used ...".

But why can I not access the method from class B? Should it not be automatically exported independently of the "next" statement?

thx
Re: tcl oo superclass does not get created when there is no "next" statement in the constructor gustafn 4/22/13 10:04 AM
I have not potential explanation for this. I think, this is a bug.
Re: tcl oo superclass does not get created when there is no "next" statement in the constructor tombert 4/23/13 2:31 AM
https://sourceforge.net/tracker/?func=detail&aid=3611641&group_id=10894&atid=110894
Re: tcl oo superclass does not get created when there is no "next" statement in the constructor pal...@yahoo.com 4/23/13 6:50 AM
What Tcl and TclOO version are you using  ? From 8.6 I get

(wits) 51 % set a [A new]
::oo::Obj63
(wits) 52 %  $a getAvar
fromA
(wits) 53 %  $a getBvar
can't read "bvar": no such variable

which is what I would expect given that B's constructor was not called.

/Ashok


On Tuesday, April 16, 2013 8:45:57 PM UTC+5:30, tombert wrote:
> Considering this example here:
..