From: chiaro scuro Date: 2006-05-02T06:38:00+09:00 Subject: Re: from block to code (also: how to get the bindings of a block) ------=_Part_20642_9496607.1146519476275 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I am aware of this technique, something very similar was also described in = a very nice article by Jim Freeze on Ruby Code and Style. The recipe is just an example as I said. Truly, I don't see why I shouldn't use the equal signs. Let's just say that the language makes it hard doing it. No hard feelings, = I still love Ruby :-) We can always do things in other ways, but that's also the argument that many javists and dotnetters use against ruby. On 5/1/06, ara.t.howard@noaa.gov wrote: > > On Tue, 2 May 2006, chiaro scuro wrote: > > > On 5/1/06, Jacob Fugal wrote: > >> > >> On 5/1/06, chiaro scuro wrote: > >> > I need to keep the equal signs. > >> > >> This is my big question; why do you need the equal signs? I see > >> nothing inherent about the "recipe" domain that makes the equal signs > >> necessary or even desirable. If you were willing to ditch them, a > >> whole slew of simpler and cleaner implementations are available. > >> > >> Jacob Fugal > >> > >> > > I realize that would make it much easier in ruby. > > It's just that the equal signs make lots of sense to my DSL users. > (forget > > the recipes, it's just an example) > > > > Look, it's not a matter of life or death. *of course* I can do without > if > > there is no alternative. > > (eventually I did find a solution to this -although it's a cheesy one- > but I > > am not saying yet ;-) > > > > It just bothers me that I cannot access that context if I need to, and > in > > this case I do. > > it would be tough to convince me that people wouldn't find this syntax > natural: > > harp:~ > cat a.rb > class Recipe < Hash > attr 'name' > def initialize name, &b > @name =3D name > instance_eval &b > end > def method_missing m, *a, &b > m =3D m.to_s.delete '=3D' > self[m] =3D a.size > 1 ? a : a.shift > end > end > def recipe(*a, &b) Recipe.new(*a, &b) end > > > > r =3D > recipe "breakfast" do > eggs 2, :big > bacon 3 > end > > p r > > > harp:~ > ruby a.rb > > > {"bacon"=3D>3, "eggs"=3D>[2, :big]} > > > for example, write down a recipe and see if you use the '=3D' sign ;-) > > regards. > > -a > -- > be kind whenever possible... it is always possible. > - h.h. the 14th dali lama > > -- Chiaroscuro --- Liquid Development: http://liquiddevelopment.blogspot.com/ ------=_Part_20642_9496607.1146519476275--