SourceForge has been redesigned. Learn more.
Close

#141 UNSETMETHOD doesn't revert

v3.0
closed
Classes (182)
5
2012-08-14
2006-04-04
Anonymous
No

Although UNSETMETHOD properly reports that HASMETHOD is
false, an attempt to invoke the method (self~method)
calls the method just unset. Windows XP SP2 OORexx 3.0.1

/ Rexx Hasmeth.rex /
/
* Example demonstrating the use of the HasMethod, the
SetMethod and the UnSetMethod
* from Object Rexx by Example by Veneskey, Trosky &
Urbaniak
/

team1 = .Football~new(Steelers, Pittsburgh, PA)
team1~location
say Team1~hasmethod(ClassStatus)
Team1~Super_ClassStatus
team1~classstatus

Team2 = .Football ~ new(Panthers, Pittsburgh, PA)
Team2 ~ location
Team2 ~ ClassStatus
Team2 ~ Set_Pitt
Team2 ~ Stadium
Team1 ~ Stadium
say Team1 ~ Hasmethod(Stadium)

::Class Sport

::Method ClassStatus
say 'This is a Professional Sports Team'

::Class Football subclass Sport

::Method init
expose team City State
use arg Team, City, State

::method Location
expose team City State
say 'The' Team' team plays in' city state

::Method ClassStatus
say 'This is a collegiate Sports Team'

::Method Super_ClassStatus
self~UNSETMETHOD(ClassStatus)
say Team1 ~ hasmethod(ClassStatus)
self~ClassStatus
/ this displays 'This is a collegiate Sports Team' /

::Method Set_Pitt
self ~ setmethod('Stadium', 'say "This team plays at
Pitt Stadium"')

::Method Unknown
expose team
say 'This method is not available to' team

Discussion

  • Nobody/Anonymous

    hasmeth.rex

     
  • Gert van der Kooij

    Logged In: YES
    user_id=685845

    When reading the docs, it looks like the unsetMethod should
    only work on methods added with setMethod or enhanced, which
    if I understand correctly means that it shouldn't work on
    the 'regular' class methods.
    This should also mean that hasMethod(ClassStatus) should
    return 1 instead of 0. Either way it is still a bug.

     
  • Mark Miesfeld

    Mark Miesfeld - 2009-07-08

    I don't see this as a bug. I take it you are concerned with this piece of code:

    ::Method Super_ClassStatus
    self~UNSETMETHOD(ClassStatus)
    say Team1 ~ hasmethod(ClassStatus)
    self~ClassStatus
    / this displays 'This is a collegiate Sports Team' /

    Gert correctly analyzed part of it. The docs say about the unset method:

    Cancels the effect of all previous setMethods for method methodname. It also removes any method methodname introduced with enhanced when the object was created. If the object has received no setMethod method, no action is taken.

    There has been no previous setMethod() for the ClassStatus() method. In addition, ClassStatus was not introduced with enhanced when the object was created. Therefore, the invocation of UNSETMETHOD(ClassStatus) causes no action to be taken. As is documented.

    But, Gert is wrong in saying that hasMethod(ClassStatus) should return 1 instead of 0.

    Team1 is not in scope in this method, so it is not a Sport object, It is a string object. And it is correct that a string object does not have the ClassStatus method.

    Adding this line to the method:

    say 'Team1 is a:' Team1

    so that the method looks like:

    ::Method Super_ClassStatus
    self~UNSETMETHOD(ClassStatus)
    say Team1 ~ hasmethod(ClassStatus)
    say 'Team1 is a:' Team1
    self~ClassStatus

    produces this output:

    E:>hasmeth
    The STEELERS team plays in PITTSBURGH PA
    1
    0
    Team1 is a: TEAM1
    This is a collegiate Sports Team
    This is a collegiate Sports Team
    The PANTHERS team plays in PITTSBURGH PA
    This is a collegiate Sports Team
    This team plays at Pitt Stadium
    This method is not available to STEELERS
    0

    E:>

    So the original opener of the bug was wrong in the use of unSetMethod(). If the docs were misleading at the time of 3.0, they have been corrected and seem clear enough to me at this time.

    Gert was wrong in saying it was a bug one way or another, perhaps mislead by the scoping of Team1.

     

Anonymous
Anonymous

Cancel  Add attachments