[Xotcl] abstract methods
Koen Danckaert
koen at retarget.com
Wed Jul 13 12:26:34 CEST 2005
Hi Uwe,
This solution indeed produces an error for the case I mentioned before, but now it also gives errors when an abstract method is invoked by "next".
I think that callingproc and callingobject cannot be used to test whether a method has been invoked by next. They are not modified through a next call, as shown by the following code:
Class C
C instproc a {} {
puts "callingproc : '[self callingproc]'"
puts "callingobject : '[self callingobject]'"
}
Class D -superclass C
D instproc a {} {next}
D instproc b {} {my a}
D test
test a
test b
This produces:
callingproc: ''
callingobject: ''
callingproc: 'b'
callingobject: '::test'
So it is as if there was no intermediate "next" call.
Koen
Uwe Zdun wrote:
> it seems you've found a bug. The Method in predefined.xotcl should
> probably look like this:
>
> ::xotcl::Object instproc abstract {methtype methname arglist} {
> if {$methtype != "proc" && $methtype != "instproc"} {
> error "invalid method type '$methtype', \
> must be either 'proc' or 'instproc'."
> }
> ::xotcl::my $methtype $methname $arglist "
> if {\[::xotcl::self callingproc\] == \[::xotcl::self proc\] &&
> \[::xotcl::self callingobject\] == \[::xotcl::self\]} {
> ::xotcl::next
> } else {
> error \"Abstract method $methname $arglist called\"
> }
> "
> }
More information about the Xotcl
mailing list