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 ---
Anonymous
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.