From: dblack@... Date: 2006-03-09T11:58:07+09:00 Subject: Re: Having a block executed in the context of an instance Hi -- On Thu, 9 Mar 2006, Logan Capaldo wrote: > > On Mar 8, 2006, at 2:09 PM, Dominik Bathon wrote: > >> On Wed, 08 Mar 2006 15:56:53 +0100, wrote: >> >>> Hi -- >>> >>> On Wed, 8 Mar 2006, itsme213 wrote: >>> >>>> I wouldn't hold my breath for := or equivalent :-) >>> >>> I have to say, I've been wondering for many years... is self.x = 1 >>> really *that* bad? It just seems like such a minor thing to me. I >>> certainly wouldn't want to see new punctuation introduced just to >>> avoid it. >> >> How about allowing >> >> .attr = val >> >> as a shortcut for >> >> self.attr = val >> >> It's no "new" punctuation and I can't see any ambiguities with current ruby >> syntax (correct me if I'm wrong). >> >> Just an idea. >> >> Dominik >> > > Hmmmmmm, It's shorter than self.attr, but on the other hand it's uglier IMO. > One question I would have to wonder is: > > self.method( ) # definitely not private > method( ) # definitely private > self.x = y # could be public or private > .x # probably(?) not private ??? > .x = y # ??? > > Oh wait I take the whole thing back, naked method( ) could be public too. I > guess throwing .x in there doesn't make the visibility any more confusing I wonder how the parser would handle: obj .x i.e., whether it would be: obj.x or obj(.x) David -- David A. Black (dblack@wobblini.net) Ruby Power and Light, LLC (http://www.rubypowerandlight.com) "Ruby for Rails" chapters now available from Manning Early Access Program! http://www.manning.com/books/black