From: "Mauricio Fernández" Date: 2003-07-17T02:47:37+09:00 Subject: Re: Keyword "with" On Wed, Jul 16, 2003 at 11:56:56PM +0900, Hal E. Fulton wrote: > > > > Actually, VB complements the 'with' block with a unary . operator, which > > is IMO the cleanest way to scope both local and object variables and > > methods. At least, when I thought of the instance_eval/with trick, I > > gave up on it because I couldn't think of a way to simulate unary .s > > Now there's a thought. The unary . is not so > bad in my opinion. We already have the unary :: > in Ruby (::X means Object::X). both 'with' and the unary '.' imply the existence of a default variable. Now consider the following: * matz (and most people here) dislikes perlish things such as $! $: ... * the default variable looks suspiciously like $_ (and by its very nature it's essentially perlish and scheduled to be phased out) ... And coming back to the 'with' thing: although I reinvented it in the past I don't think it's going to be that useful: the proposed usage is anAwfulLongIdentifierThatYouWontLiktToTypeOften = "foo" with anAwfulLongIdentifierThatYouWontLiktToTypeOften do puts length concat "bar" puts length puts self end but 1) why would anybody choose such a long identifier? After all, it's a local whose name can be taken freely. Arguing that it's necessary to prevent name collisions is IMHO mistaken: a method should normally not have so many variables that long names are needed. If you're losing clearness inside the 'with' block, why not make a better trade-off on variable assignment ("declaration")? 2) you can always do a = anAwfulLongIdentifierThatYouWontLiktToTypeOften puts a.length .... The only drawback is having to invent a new name. There's no performance impact, very unlike 'with'. -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com what's the difference between chattr and chmod? SomeLamer: man chattr > 1; man chmod > 2; diff -u 1 2 | less -- Seen on #linux on irc