View · Search · Index
No registered users in community xowiki
in last 10 minutes

Re: [Xotcl] seachDefaults?

From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Wed, 11 Aug 2010 11:30:05 +0200

  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