Gustaf (or others working on the core), you didn't say if this was an oversight of the current XOTcl documentation, or if somethins is missing on the [searchDefaults] stuff.
Check here: http://media.wu-wien.ac.at/doc/langRef-xotcl.html#Class-create
It states that the [searchDefaults] method is called to set default values for instance attributes (is this referring to parameter defaults as well?). However such a method does not exist for objects.
I would like to be able to separate allocation, defaults and initialisation (via constructor) in object instantiation.
On 10.08.10 00:38, Kristoffer Lawson wrote:
Gustaf (or others working on the core), you didn't say if this was an oversight of the current XOTcl documentation, or if somethins is missing on the [searchDefaults] stuff.
Dear Kristoffer,
I was never happy with the way how searchDefault works in xotcl 0.* and xotcl 1.*, so the missing detailed documentation discourages people to depend on it. The method "searchDefaults" is not defined on ::xotcl::Object but on the parameter class. This will change in the near future, parameter classes in general will disappear.
The object parametrization (the classical "parameters" of XOTcl) will be completely different in XOTcl 2.0, highly orthogonal with method parameterization (defining positional/non-positional, optional/required valuechecked, ... arguments for methods implemented in C or scripted). So, be warned that things will change in this area.
However, providing an answer to your question: Experienced xotcl users use a filter to figure out the details: =============================================== Object instproc traceFilter args { set context "[self class]->[self callingproc]" set method [self calledproc] switch -- $method { proc - instproc {::set dargs [list [lindex $args 0] [lindex $args 1] ...] } default {::set dargs $args } } puts "CALL $context> [self]->$method $dargs" set result [next] puts "EXIT $context> [self]->$method ($result)" return $result }
Class create Car -parameter {{wheels 4} {color white}} Class create Ford -superclass Car -parameter {{color black}}
Object instfilter traceFilter Ford create t-model Object instfilter "" ===============================================
If you want, you can define an object-specific method such you do not have to mess much with the parameter classes:
=============================================== ::xotcl::Object instproc set_instance_vars_defaults {} { set pcl [[my info class] info parameterclass] $pcl searchDefaults [self] } ===============================================
Best regards -gustaf neumann
On 11 Aug 2010, at 12:30, Gustaf Neumann wrote:
I was never happy with the way how searchDefault works in xotcl 0.* and xotcl 1.*, so the missing detailed documentation discourages people to depend on it. The method "searchDefaults" is not defined on ::xotcl::Object but on the parameter class. This will change in the near future, parameter classes in general will disappear.
OK, thanks, Gustaf, for the clarification! Should this be mentioned in the documentation, as searchDefaults is only referred to in one place (create)? Even if it is just to say that this behaviour shouldn't be relied on for the future and use is discouraged.