From: eregontp@... Date: 2021-06-06T09:43:56+00:00 Subject: [ruby-core:104177] [Ruby master Feature#17938] Keyword alternative for boolean positional arguments Issue #17938 has been updated by Eregon (Benoit Daloze). File Screenshot from 2021-06-06 11-37-44.png added I'm negative about this, because of the overhead and complexity it would introduce while supporting both forms, and because it seems difficult (and annoying) to ever remove the current positional argument. FWIW, some IDEs shows argument names, for example RubyMine: ![](Screenshot from 2021-06-06 11-37-44.png) (It does not work for respond_to?, but that seems simply a limitation of the stub method in RubyMine) I think this is potentially a place where editor integration with rbs/Sorbet could help too (notably by having precise signatures for core methods). In general, it feels like an editor issue to me, rather than an issue in Ruby, and I think the cost to change all those APIs would be too great and too costly for performance and maintainability. ---------------------------------------- Feature #17938: Keyword alternative for boolean positional arguments https://bugs.ruby-lang.org/issues/17938#change-92354 * Author: matheusrich (Matheus Richard) * Status: Open * Priority: Normal ---------------------------------------- Some Ruby methods accept optional boolean arguments. This kind of parameter is known to be confusing since you cannot tell just looking at the method call what the parameter mean. For example: ```ruby object.respond_to?(:symbol, false) # what does `false` mean? object.methods(true) # what does `true` mean? ``` Now compare that to ```ruby object.respond_to?(:symbol, include_all: false) object.methods(regular: true) # or object.methods(only_public: true) # or object.methods(include_all: false) ``` I know Matz doesn't like breaking changes, so maybe we could have both to not break current calls, but allow a nicer syntax in newer Ruby? I don't know the depths of the Ruby C implementation, so here's what I thought in plain Ruby: ```ruby def respond_to?(symbol, include_all_positional=false, include_all: nil) include_all ||= include_all_positional # ... end ``` I'm willing to tackle this, if approved. ---Files-------------------------------- Screenshot from 2021-06-06 11-37-44.png (5.63 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: