<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I was in the process of writing this email to ask whether XOTcl currently supports, or could easily be extended to support, a particular pattern of parameter defaults that I often use, and then was pleased to discover that XOTcl already provides most of what I was looking for.  Though, it's not documented as such, so I'm not certain whether this was intentional.  I suspect it may have been a side effect of the generality of parameters.  I don't mean to dismiss the foresight of the XOTcl authors, but since it is a simple mechanism, and not documented, I am concerned that the feature may disappear in the future.  </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The pattern is simple - parameter defaults, instead of being constants, should be changeable so that client code can modify the defaults as desired.  For example, if the default is a class variable, then client code can modify the class variable.  Then, when a new instance is created, the new default is used.  To extend the example from the tutorial:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>Car set doors 8</FONT></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>C</FONT><FONT class="Apple-style-span" face="Monaco">ar create limo</FONT></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>limo doors</FONT></FONT><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco">; # ==&gt; 8</FONT></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>Car set doors 5</FONT></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>C</FONT><FONT class="Apple-style-span" face="Monaco">ar create minivan</FONT></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>minivan doors<SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>;</FONT></FONT><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"> # ==&gt; 5</FONT></FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I originally supported this pattern by putting the appropriate intelligence in the init instproc.  But, since I use this pattern a lot, I saw that code commonly in many of my init instprocs.  So, I was looking to find a way to have XOTcl automatically pick up the default from the class.  I decided that the most general thing to do was to put a script in the default and then execute it.  But, when I tried that, I found that XOTcl executed the script for me!  So, to support the above, I simply did:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>Class create Car -parameter { {doors {[[self class] set doors]}} }</FONT></FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I also found that the default can be a simple variable, though accessing it requires scope qualifiers (but, I find this much less useful):</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco">Class create Car -parameter { {doors $::DOORS} }</FONT></FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco">set DOORS 4</FONT></FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco">Car create sedan</FONT></FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco">sedan doors</FONT></FONT><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco">; # ==&gt; 4</FONT></FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Obviously, XOTcl supports much more general default behavior than I was originally looking for.  But, for me, this is the appropriate solution.  I can express simple defaults very simply.  If I am looking for something more complicated, I can create a proc to support it, and then have the proc called.  </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Note that with parametercmd we can make this slightly cleaner to use:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>Class create Car -parameter { {doors {[[self class] doors]}} }</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>Car parametercmd doors</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco"><BR class="khtml-block-placeholder"></FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>Car doors 8</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>C</FONT><FONT class="Apple-style-span" face="Monaco">ar create limo</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>limo doors</FONT><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" face="Monaco">; # ==&gt; 8</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>Car doors 5</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>C</FONT><FONT class="Apple-style-span" face="Monaco">ar create minivan</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>minivan doors</FONT><SPAN class="Apple-tab-span" style="white-space:pre; font-family: Monaco; ">        </SPAN><FONT class="Apple-style-span" face="Monaco">;</FONT><FONT class="Apple-style-span" face="Monaco"> # ==&gt; 5</FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>This then begs for automatic creation of the parametercmd on the class.  I had hoped that this could be accomplished by subclassing Class::Parameter and extending the init instproc (note that I had to actually use ::xotcl::Class::Parameter), but this did not work:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>Class MyParameter -superclass ::xotcl::Class::Parameter</FONT></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>MyParameter instproc init args {</FONT></FONT><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"></FONT></FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre; font-family: Monaco; ">                </SPAN><FONT class="Apple-style-span" face="Monaco">##  I would like to create parametercmd's on the class here;</FONT> <FONT class="Apple-style-span" face="Monaco">but, I need a handle </FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>##  to the class.  Is it one of the args?  </FONT><FONT class="Apple-style-span" face="Monaco">Let's find out:</FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>puts [info level 0]</FONT></FONT><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"></FONT></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>next</FONT></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>}</FONT></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>Class create Car -parameterclass MyParameter -parameter { {color green} }</FONT></FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>## Hmm - didn't see what I hoped I would see.  </FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>Car create ferrari</FONT></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>## init ::ferrari</FONT></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>## ::ferrari</FONT></FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>## Ok, this is where the parameter gets instantiated.  So, how do the instparametercmd's get created?</FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Maybe there is no hook for me to do what I'm trying to do?  Maybe I just have to accept manually adding the parametercmd to the class?  It's not such a big deal, but I thought it might be useful.  </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Thanks,</DIV><DIV>Kurt Stoll</DIV><DIV><BR class="khtml-block-placeholder"></DIV></BODY></HTML>