No registered users in community xowiki
in last 10 minutes
in last 10 minutes
[Xotcl] abstract methods
From: Koen Danckaert <koen_at_retarget.com>
Date: Thu, 07 Jul 2005 10:09:21 +0200
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
Date: Thu, 07 Jul 2005 10:09:21 +0200
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