In XOTcl (1.3.8) there seems to be no initialisation of parameters during dynamic class change. See code below: a1 and a2 behave differently.
Is this the intended behaviour?
- regards, Florian
package require XOTcl namespace import xotcl::* eval [string map {INFO {[self] [info level 0] : [my info class] : [my info vars]}} { Class A -parameter { {p 0} } A instproc pp {} { puts "A INFO"; next }
Class B -superclass A -parameter { {q 0} } B instproc pp {} { puts "B INFO"; next } }]
proc main {} { set strich "--------------------------------------------------------------"
puts $strich A create a1 -p a1 a1 class B #a1 init a1 pp #puts "a1 q = [a1 q]" ;# should this be an error?
puts $strich
A create a2 -p a2 a2 class B a2 q xx a2 pp #puts "a2 q = [a2 q]" puts $strich } main
Murr, Florian schrieb:
In XOTcl (1.3.8) there seems to be no initialisation of parameters during dynamic class change.
this is intended behavior. when an object changes its class, it is not clear that someone want's to re-initialize variables, etc.. btw, there is a similar situation, when mixining-in classes with parameter definitions.
See code below: a1 and a2 behave differently.
they don't behave differently on themselves, you are doing different things there. certainly, when you call a method setting an instvar, it is afterwards there, if you don't call it, its not there.
I think, you question is: how can i get the default values from parameters set, when i change dynamically the class. The following definition helps you with that:
============================= Object instmixin add \ [Class new -instproc class args {next; ::xotcl::Class::Parameter searchDefaults [self]}] =============================
btw, you can get rid of the string-map-INFO business by using
... package require xotcl::trace ... A instproc pp {} { my showVars } ...
hope this helps -gustaf neumann