Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#527 "FORWARD TO (dirObj)" does not work always

3.2.0
closed
nobody
None
5
2012-08-14
2008-08-31
Anonymous
No

Forwarding messages to a directory object does not work in all cases:

--- cut here ---
say "Forwarding messages to a directory object:"
say ".abc~items: " .abc~items
say ".abc~aha: " .abc~aha
say ".abc~hasIndex('AHA'):" .abc~hasIndex('AHA')
say ".abc~hasItem(1): " .abc~hasItem(123)
.abc~aha=123
say ".abc~items: " .abc~items
say ".abc~aha: " .abc~aha
say ".abc~hasIndex('AHA'):" .abc~hasIndex('AHA')
say ".abc~hasItem(1): " .abc~hasItem(123)
say "---"

say "Sending messages directly to a directory object:"
xyz=.directory~new
say "xyz~items: " xyz~items
say "xyz~aha: " xyz~aha
say "xyz~hasIndex('AHA'): " xyz~hasIndex('AHA')
say "xyz~hasItem(1): " xyz~hasItem(123)
xyz~aha=123
say "xyz~items: " xyz~items
say "xyz~aha: " xyz~aha
say "xyz~hasIndex('AHA'): " xyz~hasIndex('AHA')
say "xyz~hasItem(1): " xyz~hasItem(123)

::class abc
::method init class
expose dir
dir=.directory~new

::method unknown class
expose dir
forward to (dir) / <-- does not handle Items(), HasIndex(), etc. correctly! /
--- cut here ---

Discussion

  • Rick McGuire
    Rick McGuire
    2008-08-31

    Logged In: YES
    user_id=1125291
    Originator: NO

    This is working correctly. The unknown method of the directory class is that catcher of last resort that allows syntax such as

    d = .directory~new
    d~foo = "Fred"
    say d~foo

    to work. As such, the unknown method gets invoked only when other method look ups have failed. Since your unknown method is just forwarding the method as is, it is directly invoking the directory unknown method rather than directly invoking the general method look ups.

     


Anonymous


Cancel   Add attachments