I am playing with configure in new version tcl9.0, it works, but I have the question: how to make class both configurable and abstract? I tried to do like this:
oo::abstract create Simulator {
mixin oo::configurable
property Name -set {
error "Not implemented"
}
variable Name
}
But it raises the error that property is not known. Thank you in advance!
You need to do:
oo::configurable create Simulator {
self mixin -append oo::abstract
property Name -set {
error "Not implemented"
}
variable Name
}
This is because oo::configurable
does cunning things to add property
to the set of configuration commands, and that means it needs to be asserted prior to oo::define
being called (yes, classes just hand that off in their constructor); adding it during the call would mean that only the next time oo::define
is called would it be impacted.
By contrast, oo::singleton
is very simple; it currently just makes create
and new
be non-exported methods on the class concerned directly (but not its subclasses) and doesn't alter the definition command context. That makes it simple enough to work as a mixin. We use self mixin -append
because we may add other mixins to classes, and want to affect the class object itself.