[Xotcl] info method behaviour

Artur Trzewik mail@xdobry.de
Sun, 12 Aug 2001 11:29:14 +0200


On Saturday 11 August 2001 23:07, you wrote:
> On Sat, 11 Aug 2001, Zoran Vasiljevic wrote:
> > You can do this pretty easy with:
> >
> > % [ob info class] info instprocs
> >
> > ... and similar.
>
> That is what I do, but required me to know that a proc is inherited
> from somewhere! I have both types, procs and instprocs (which are both
> callable from the object) and I would like to be able to ask information
> about them without knowing where they're from.
>
> > AFAIK, the "ob info procs|args|body" is ment to be used
> > with per-object resources (procs), like for example:
>
> Yes, that what it appears to do, but as such it's limited. I would like
> a uniform way of asking information about inherited procs and per-instance
> procs. In fact I might even say that to separate those on this level is
> confusing the object model.

I know this problem. The possible solution is to use procsearch function if 
you know the name of method

set proc [$ob procsearch proc]

and ask the standard tcl info
if  {$proc!=""}  {
  info args $proc
}

To get all posible methods for some object in not so easy. I use something 
like that in XOTclIDE

Class instproc getAllInstMethods {} {
    set methods [[self] info instprocs]
    foreach class [[self] info heritage] {
	set methods [concat $methods [$class info instprocs]]
    }
    return [lsort -unique $methods]
}

You also must look for all mixins classes and procs methods
$object info mixin

Object instproc allAvailableMethods {} {
     ::set method {}
     foreach class [concat [[self] info class] [[self] info mixin]] {
           ::set method [concat $method [$class getAllInstMethods]]
     }
     ::set method [concat $method [[self] info procs]]
     return [lsort -unique $method]
}

There are also class mixins (not implemented above).

happy hacking
Artur Trzewik