From: Charles Oliver Nutter Date: 2011-01-20T07:35:44+09:00 Subject: [ruby-core:34629] Re: [Ruby 1.9-Feature#4288][Open] Allow invoking arbitrary method names with foo."something" syntax On Wed, Jan 19, 2011 at 2:58 PM, Gary Wright wrote: > Maybe I'm crazy, but could I suggest something a little more general? > > �� foo.{expression}(arg1) > > to have the same semantics as > > ��foo.send(expression, arg1) I don't want something that just resolves to doing "send" under the covers. I want this code: foo."something"() to parse identically to: foo.something() What I want is purely a syntax-level quoting mechanism for method invocation. > I've always found the use of Kernel#send for dynamic method dispatch to be a bit awkward and would prefer something that was syntactically similar to static method dispatch rather than the current dependency on the 'magic' behavior of Kernel#send. I agree, but "send" also changes things in subtle ways. I just want a way to specify a syntactically "unfriendly" method call and have it actually resolve to a plain old CALL, FCALL, or VCALL (in MRI AST parlance). FWIW, there have been proposals to add this sort of "symbolic freedom" to Java method invocations using a similar form: foo.#"something" - Charlie > Perhaps a syntactic approach to dynamic dispatch would enable more interesting optimizations since it would be clear that something 'interesting' was going on rather than just a generic method call to a magic method like Kernel#send. If you mean that the above syntax would actually parse to those literal call names (rather than bouncing through send) then I have no objections. I feel like foo."something" is cleaner, though, and the {} immediately says "block" to me. If that was your intent...I think that's going a bit too far :) - Charlie