It seems that [variable] within class declaration doesn't 'accumulate' variable names, so there can only be a single [variable] in the declaration.
I would expect the following to produce "moop v3 1" instead of erroring.
package require TclOO
namespace import oo::*
class create Vartest {
variable v3
variable v1 v2
method moop {v} {
puts stderr "moop $v [set $v]"
}
method woo {} {
my moop v1
my moop v2
my moop v3
}
constructor {} {
set v1 1
set v2 1
set v3 1
}
}
Vartest create test
test woo
PRODUCES:
tclsh8.6 tcloo.tcl
moop v1 1
moop v2 1
can't read "v3": no such variable
while executing
"set $v"
(class "::Vartest" method "moop" line 2)
invoked from within
"my moop v3"
(class "::Vartest" method "woo" line 4)
invoked from within
"test woo"
(file "tcloo.tcl" line 24)
Right now, the 'variable' declaration 'sets' rather than 'appends'. In this, it is like the 'superclasses', 'mixins' and 'filters' decls.
Arguably this should be different; I'm in two minds about it.
Right now, the 'variable' declaration 'sets' rather than 'appends'. In this, it is like the 'superclasses', 'mixins' and 'filters' decls.
Arguably this should be different; I'm in two minds about it.
I don't mind which way it works, although I tend to like to have a variable declaration with associated comments.
I'd expected it to be like [method] rather than [superclass], but can live with however it falls. Possibly this needs to be more clearly documented.
Hello Donal,
Just to remind you...
What do you intend to do for this?
Personnaly, I would prefer the 'append' behaviour.
The 'set' behaviour is not usual in Tcl.
“Do”? It's working as specified and as documented.
As this is really a FRQ for a slot-like management scheme for variables, I'm moving this to another tracker.
Note that this sort of thing ought to be applied to the other list-of-things declarations too. Broadening FRQ scope.
This was TIP #380, and is applied.