[Xotcl] Changing a parameter's -setter function

Scott Gargash scottg at atc.creative.com
Wed Mar 15 00:07:29 CET 2006






Hello,

Is it possible to change the -setter command associated with a parameter at some point other than
class definition?  I want to trigger some side effects from a parameter set operation, but I can't
trigger the side effects until after other things have been initialized, so I want to use the
default setter method until the end of init, and then replace the setter method (but not the getter
method).

I can override create a parameter-named method at init time, but that overrides the getter along
with the setter. I'd rather not have to handle the -getter from my proc (the default -getter is fine
and 2.5x faster).  I've looked through the docs and the tutorial and I can get tantalizingly close
(parametercmd), but is there an easy way from within a proc to change the -setter properties of a
parameter?

Something like this:

Class create a -parameter {{foo 1}}
a instproc foosetter {var val} {
  # Do something with [self] that isn't valid pre-init
}
a instproc init {} {
  #override foo's -setter parameter cmd
  my parametercmd foo -setter foosetter
}

a create b -foo 234 ;# calls default foo setter
b foo   ;# calls default foo getter
b foo 123 ;# calls overridden foosetter

Thanks for your help.  XOTcl is a great.  It should be adopted as Tcl's standard OO package.

      Scott

Notice
The information in this message is confidential and may be legally privileged.  It is intended
solely for the addressee.  Access to this message by anyone else is unauthorized.  If you are not
the intended recipient,  any disclosure,  copying or distribution of the message,  or any action
taken by you in reliance on it,  is prohibited and may be unlawful.  If you have received this
message in error,  please delete it and contact the sender immediately.  Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://alice.wu-wien.ac.at/pipermail/xotcl/attachments/20060314/2df7d273/attachment.html


More information about the Xotcl mailing list