[Xotcl] abstract methods

Koen Danckaert koen at retarget.com
Thu Jul 7 10:09:21 CEST 2005


Hello,

The XOTcl manual says that an abstract method produces an error if it is called directly. It seems that this is not always the case. E.g., in the following example there is no error:

Class C
C abstract instproc a {}
C instproc b {} {my a}

C test
test b


>From an earlier discussion on the mailing list I found that predefined.xotcl contains the following code to avoid errors when an abstract method is invoked by "next":

Object instproc abstract {methtype methname arglist} {
  if {$methtype  != "proc" && $methtype != "instproc"} {
    error "invalid method type '$methtype', \
	must be either 'proc' or 'instproc'."
  }
  [self] $methtype $methname $arglist "
    if {\[self callingproc\] != \[self proc\] && 
	\[self callingobject\] != \[self\]} {
      error \"Abstract method $methname $arglist called\"
    }
  "
}

I guess the test should be "||" instead of "&&" ?
But then, it doesn't do the right thing either, because callingproc is empty in case of an invocation by "next".


Regards,
Koen Danckaert


More information about the Xotcl mailing list