From: David Alan Black Date: 2001-08-02T00:00:56+09:00 Subject: [ruby-talk:18965] Re: Using "@" as a method name? Hello -- On Wed, 1 Aug 2001, Dave Thomas wrote: > Laurent Julliard writes: > > > myvar = @"A sample string" > > ... > > > PS: For those of you who know Objective C and the GNUstep environment > > you probably see what I want to achieve. In this environment saying > > @"string" has the same effect as saying NSString.new("string") in Ruby > > and I'd like to replicate this behavior in Ruby > > On a related note: it would be nice to be able to have the ability to > extend the repertoire of % commands. How about having > > %c{...} > > (where c is any character) invoke Kernel.build_, so > > %T{wombat} > > would call Kernel.build_T(), passing in "wombat". > > Is this a viable RCR? Post it to RubyGarden and find out :-) A couple of musings and/or questions: What would get passed to #build_T for these: %T{wombat combat tomcat comsat} %T{wombat #{combat} "tomcat #{comsat}"} Ideally #build_T would make the decisions about what approach to take to interpolation, but the arguments have to get sent to #build_T before those decisions are known. One other thing: maybe using a hash of procs, rather than dynamically named methods, might be good (whatever "good" means; it probably means that I like hashes of procs :-) Kernel.quoter(:T) = proc { ... } David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav