On 10/27/06, matt neuburg <matt / tidbits.com> wrote: > Some languages have a "with" construction, where undefined methods are > routed to a designated object. Here's an example from UserTalk: > > with system.startup { > string(license) > } > > UserTalk knows what "string" is, but when it can't find "license" it > reinterprets it as system.startup.license, which works. Barebones approach: system.startup.instance_eval do ... end instance_eval sets "self" for the block so all messages with an implicit receiver go to it's receiver. > In UserTalk, you can even chain these tests: > > with system.temp, system.startup { > string(license) > } This is a little harder, in that you can't do it with one already existing method, but it is possible. A way in which I can think of doing it is to create a proxy instance that can contain multiple target instances. The first target instance (they're ordered by priority) that responds to the message will process it. A "with" method that automatically creates this proxy around it's arguments then instance_evals that block on the proxy would do what you're looking for, I think. The code to actually do the above is left as an exercise for the reader. ;) Jacob Fugal