[ruby-core:95518] [Ruby master Feature#16275] Revert `.:` syntax
From:
mame@...
Date:
2019-10-23 23:19:50 UTC
List:
ruby-core #95518
Issue #16275 has been updated by mame (Yusuke Endoh).
+1 for the removal of `.:`.
> Originally it was to extract the exact method even if obj.method was overridden.
I think that it was just one of the motivations of that. Anyway, people will mainly (ab)use it like `.map(&JSON.:parse)`. I don't like this style. It is ad-hoc, incomplete, not composable, just hacky, and even complicated.
I'm currently thinking that the following design is preferable.
* A plain old style should be the base: `.map {|x| x.to_s(16) }` `.map {|x| JSON.parse(x) }`
* A numbered parameter makes simple cases simpler: `.map { _1.to_s(16) }` `.map { JSON.parse(_1) }`
* #16120 is worth reconsidering which makes typical case rather simpler: `.map { .to_s(16) }` (and this style is more flexible than the current `.map(&:to_s)`)
* `.map(&:to_s)` should be deprecated
----------------------------------------
Feature #16275: Revert `.:` syntax
https://bugs.ruby-lang.org/issues/16275#change-82292
* Author: naruse (Yui NARUSE)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
`obj.:method` is introduced at r66667 by #12125 and #13581.
It encourages the functional programming style in Ruby.
But this shorthand syntax is just for methods of `self` without arguments.
It causes another feature requests like #16273 (and lambda compositions like #15428).
Such features will introduce a new view of Ruby but no one illustrates the whole picture yet.
I worried about such patch work may cause a conflict with future expansion of functional programing style or a just a garbage feature.
`.:` syntax is introduced in 2.7.0 preview1, not released in production yet.
How about reverting at this time and re-introduce with a big picture.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>