From: Charles Oliver Nutter Date: 2011-01-21T06:37:52+09:00 Subject: [ruby-core:34685] Re: [Ruby 1.9-Feature#4288][Open] Allow invoking arbitrary method names with foo."something" syntax On Wed, Jan 19, 2011 at 6:03 PM, Gary Wright wrote: > I probably wasn't clear. I also don't want syntactic sugar for #send > but instead a way to dynamically name a method without the extra step > of looking up the implementation of #send. Ok, cool. > I was trying to expand on your idea a bit to produce a more > general approach that still addressed your use case: > > ��foo.{"something"}() > > can still be optimized to the same parse tree as > > ��foo.something() > > but it also admits the use of an arbitrary expression to generate > the name of the method to call. It does, but my concern with it is that (in the same way as string-interpolated ."" syntax) it can't be made 100% parse-time. So I think the questions to be answered are (in this order): 1. Do we feel it's useful to have a quoting mechanism for method invocation (that does not use send)? 2. Do we want that mechanism to allow runtime determination of the method to be called (and how does this water down the value of a pure-syntactical quoting mechanism)? 3. Do we want the runtime determination to allow arbitrary code Given that an interpolated mechanism could basically introduce any code, your syntax and string-interpolated syntax are largely the same feature (i.e. they both go all the way to (3) above. I definitely want (1). I'm far more dubious on the value of (2) and (3) weighed against the benefit... > BTW, I suspect that any of these ideas (single quotes, double quotes, or braces) is going to complicate the parser... Perhaps not as much as you might expect; a " is not a valid token after a ".", so there's no ambiguity. - Charlie