From: Tanner Burson Date: 2006-03-09T01:49:04+09:00 Subject: Re: Having a block executed in the context of an instance ------=_Part_13346_20782533.1141836529188 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 3/8/06, Mike Austin wrote: > > rmagick@gmail.com wrote: > > dblack@wobblini.net wrote: > > > >> I have to say, I've been wondering for many years... is self.x =3D 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. > > > > +1 > > It may be a minor syntax thing, but I think it creates unnecessary > ambiguity. > If there is a method called caption=3D(), I expect it to use that. I don= 't > write > 'self' anywhere else in Ruby, so it just seems odd. Plus is helps reduce > hard > to debug locals creation by misspellings. > > class Button > attr :caption, true > > def initialize(*args, &block) > instance_eval &block > end > end > > button =3D Button.new do > var :x > caption =3D 'Click Me' > end If you don't mind dropping the equals sign it's a pretty easy fix. At that point you could even do some method_missing magic and have it check for existing attributes and use those. There is already 'attr' for classes, why not 'local' or 'var' for > methods? One > issue is that you can't assign and declare on the same line. It could be > done > with a hash but that might look funny? > > Take this all with a grain of salt. I'm always looking for different way= s > of > doing things. I.e. to find good ideas you have to find bad ideas ;) And as david said, really the lack of a receiver is the exception not the rule. Mike > > -- =3D=3D=3DTanner Burson=3D=3D=3D tanner.burson@gmail.com http://tannerburson.com <---Might even work one day... ------=_Part_13346_20782533.1141836529188--