[Xotcl] Help: Meta-class and derived Classes

Sheik Yussuff sheik at carib-link.net
Sun Jul 22 04:41:17 CEST 2001


Class A is a derived class of meta-class Consultation.
In the filter conFilter I would like to obtain
the class of the object that received the message "m"
when invoking the command: [a m 123]. That is, the
class of the original receiver of method "m".
(Please see code below).

Thanks for any help.

Regards
sheik
.........................................................
#Code:
Class Consultation  -superclass Class

Consultation instproc conFilter args {
  set method [self calledproc]
  
  #The following is of course not correct!
  #[self class] evaluates to Consultation;
  #I need it to evaluate to A. Help!!

  if {[[self class] info instprocs $method] == ""} {
    if { [[self] exists delegate] } {
      return [eval [[self] set delegate] $method $args]
    } 
  } 
  next
}

Consultation instproc init args {
  [self] instproc setDelegate {d} {
    [self] set delegate $d
  }
  next
  [self] filterappend [self class]::conFilter
}

Consultation A -parameter delegate


A instproc m {x} {
  puts "[self] [self class] [self proc] $x"
  return [next]
}

Class B
B instproc m {x} {
  puts "[self] [self class] [self proc] $x"
  return [next]
}

A a
B b
a setDelegate b
# send message m to object a
puts "result = [a m 123]"





More information about the Xotcl mailing list