View · Search · Index
No registered users in community xowiki
in last 10 minutes

[Xotcl] Re: [Xotcl] abstract method difference 0.83->0.84

From: Uwe Zdun <uwe.zdun_at_uni-essen.de>
Date: Wed, 9 May 2001 09:17:31 +0200

Ok. First: we didn't realize there is a change from 0.83->0.84 ... we thought
the error message would occur in 0.83 as well.

Second: I agree, the behavior with "next" is undesirable ... I remember,
we've found this problem before. I wonder why we haven't changed the behavior
yet. Anyway, I think a good solution is to change the behvaior of "abstract"
accordingly. In 0.84 (and 0.83?) it was:


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 \
    [list error "Abstract method $methname $arglist called"]
}


I would propose to change it to:


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\"
    }
  "
}


That is, when the calling method name equals the current method and the
calling object is self, then the call is done with next. In this cases we
omit the error message. An example:


Class Foo
Foo abstract instproc blah {}
Class Bar -superclass Foo
Bar instproc blah {} {
  puts "Bar--blah"
  next
}

puts [Foo info instbody blah]

# here no error occurs:
Bar b
b blah

# here we still get an error:
Foo a
a blah


I'll attach my predefined.xotcl for your convenience (that is, you have to
recompile XOTcl with it in order to use the change ...)

--Uwe


On Wednesday 09 May 2001 02:13, you wrote:
> Just wanted to note a change I noticed from 0.83->0.84 which doesn't seem
> to be in the changes file? It's to do with abstract methods and code like
> the following:
>
> Class Foo
> Foo abstract instproc blah {}
>
> Class Bar -superclass Foo
> Bar instproc instproc blah {
> puts "blah"
> next
> }
>
> With 0.83 this worked but it gives an error about an abstract method
> being called in 0.84. The reason the "next" is there in the first place is
> basically because if someone decides to add a class to the chain after Bar
> then the "next" commands will already be in place. Are there other
> arguments for/against the 0.84 model?
>
> - ---------- = = ---------//--+
>
> | / Kristoffer Lawson | www.fishpool.fi|.com
>
> +-> | setok_at_fishpool.com | - - --+------
>
> |-- Fishpool Creations Ltd - / |
>
> +-------- = - - - = --------- /~setok/
>
>
> _______________________________________________
> Xotcl mailing list - Xotcl_at_wi.wu-wien.ac.at
> http://wi.wu-wien.ac.at/mailman/listinfo/xotcl

-- 
Uwe Zdun
Specification of Software Systems, University of Essen
Phone: +49 201 81 00 332, Fax: +49 201 81 00 398
zdun_at_xotcl.org, uwe.zdun_at_uni-essen.de