From: matt@... (matt neuburg) Date: 2006-10-28T03:20:14+09:00 Subject: Re: can there be a "with" construction? Jacob Fugal wrote: > On 10/27/06, matt neuburg 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. Perfect-o-rama! So I can use "with" syntax by defining this: def with(ref, &block) ref.instance_eval &block end Thanks, that's great. m. -- matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/ Tiger - http://www.takecontrolbooks.com/tiger-customizing.html AppleScript - http://www.amazon.com/gp/product/0596102119 Read TidBITS! It's free and smart. http://www.tidbits.com