Re:"Useless syntax sugar": Numbered block parameters in Ruby
by vidarh on Wednesday October 11, 2023 @10:26AM
(#37844806)
"Just passing a function" is incompatible with Ruby's current syntax where a bare method name calls the method unless you then introduce a way for method definitions to defer evaluation of its arguments, but then you open a can of worms given that Ruby allows aliasing and replacing arbitrary methods of already defined classes. I suspect it'd be a nightmare of inconsistencies.
[ Parent
| on HN ]
Re:"Useless syntax sugar": Numbered block parameters in Ruby
by graypegg on Wednesday October 11, 2023 @05:54PM
(#37850733)
It’s a bit pedantic to mention, but there is #method(:method_symbol), and obviously &:method_symbol for some cases. Both of which give you a proc you could call later with arguments provided to it. It’s not “the function” since, it’s really an anonymous function, bound to something, that will send :method_symbol to that thing. Gets around the bare-method-runs-method and metaprogramming issues with current Ruby syntax.
Re:"Useless syntax sugar": Numbered block parameters in Ruby
by vidarh on Thursday October 12, 2023 @07:09AM
(#37855661)
The entire point was that those constructs that do not just pass the bare method or something like a Proc that allows you to call the method, are needed exactly because the syntax will not allow for just mentioning a bare method name without calling it.
If you're fine with the extra syntax, yes, there are many alternatives, but they don't address the point.