[ruby-core:120747] [Ruby master Feature#21082] Alias it to its

Issue #21082 has been reported by northeastprince (Matt Almeida). ---------------------------------------- Feature #21082: Alias it to its https://bugs.ruby-lang.org/issues/21082 * Author: northeastprince (Matt Almeida) * Status: Open ---------------------------------------- One of Ruby's core tenants is beautiful code - and a key part of that is sweating names. Adding `it` as a pointer to the first block parameter was a huge step forward in that regard, but we're not done yet. If `[1, 2, 3].each { puts it }` works, `posts.each { puts its.title }` should work too. -- https://bugs.ruby-lang.org/

Issue #21082 has been updated by duerst (Martin Dürst). northeastprince (Matt Almeida) wrote:
One of Ruby's core tenants is beautiful code - and a key part of that is sweating the names. Adding `it` as a pointer to the first block parameter was a huge step forward in that regard, but we're not done yet. If `[1, 2, 3].each { puts it }` works, `posts.each { puts its.title }` should work too.
I propose we reject this. First, we have only just recently introduced `it`. It (sic!) definitely makes sense to wait and get experience with `it` before we add a variant. Second, Ruby has up to now rejected grammatical inflections such as `includes` instead of `include`. Third, if we accept a possessive ending, we would have to do it in general. `posts.each { |post| puts post's.title }` (or some such, we'd have to figure out a solution for the apostrophe, maybe just leave it out). Fourth, in `something.title`, the period already indicates a possessive relation in many cases, in particular if the following method name is read as a noun. Adding the `s` would lead to something like a double possessive ("the title of of it", so to say). Fifth, the use of `s` endings in variable names in programming languages is mostly associated with plural (`element`: single element; `elements`: array or hash of elements), much more so than in English, where a final 's' can indicate a third person singular in a verb, a plural in a noun, or a possessive (usually with an apostrophe). So when I first saw `its` in the example, I was actually thinking about an operation on an array, despite the fact that the plural of 'it' in English is of course 'they', not 'its'. In conclusion, let's reject this. ---------------------------------------- Feature #21082: Alias it to its https://bugs.ruby-lang.org/issues/21082#change-111617 * Author: northeastprince (Matt Almeida) * Status: Open ---------------------------------------- One of Ruby's core tenants is beautiful code - and a key part of that is sweating the names. Adding `it` as a pointer to the first block parameter was a huge step forward in that regard, but we're not done yet. If `[1, 2, 3].each { puts it }` works, `posts.each { puts its.title }` should work too. -- https://bugs.ruby-lang.org/

Issue #21082 has been updated by northeastprince (Matt Almeida). Hey Martin! Thanks for your input. It seems like there's a very small amount of core method names that would have such a level of linguistic dissonance based on the receiver. However, even something like `ledger.include? transaction` seems more adaptive than `it.title`, though that might just be me. Happy to let `it` sit for a while before any changes are considered 😆. ---------------------------------------- Feature #21082: Alias it to its https://bugs.ruby-lang.org/issues/21082#change-111618 * Author: northeastprince (Matt Almeida) * Status: Open ---------------------------------------- One of Ruby's core tenants is beautiful code - and a key part of that is sweating the names. Adding `it` as a pointer to the first block parameter was a huge step forward in that regard, but we're not done yet. If `[1, 2, 3].each { puts it }` works, `posts.each { puts its.title }` should work too. -- https://bugs.ruby-lang.org/

Issue #21082 has been updated by Earlopain (Earlopain _).
Second, Ruby has up to now rejected grammatical inflections such as includes instead of include.
`File.exists?` was even removed. Many methods could do with a alias that reads nicer in certain situations. For example, `posts.each { put its.title }` looks even better to me but where do you stop? ---------------------------------------- Feature #21082: Alias it to its https://bugs.ruby-lang.org/issues/21082#change-111622 * Author: northeastprince (Matt Almeida) * Status: Open ---------------------------------------- One of Ruby's core tenants is beautiful code - and a key part of that is sweating the names. Adding `it` as a pointer to the first block parameter was a huge step forward in that regard, but we're not done yet. If `[1, 2, 3].each { puts it }` works, `posts.each { puts its.title }` should work too. -- https://bugs.ruby-lang.org/

Issue #21082 has been updated by matz (Yukihiro Matsumoto). Status changed from Open to Rejected Some people want to make Ruby more English-like, but I don't agree with that direction. Matz. ---------------------------------------- Feature #21082: Alias it to its https://bugs.ruby-lang.org/issues/21082#change-111866 * Author: northeastprince (Matt Almeida) * Status: Rejected ---------------------------------------- One of Ruby's core tenants is beautiful code - and a key part of that is sweating the names. Adding `it` as a pointer to the first block parameter was a huge step forward in that regard, but we're not done yet. If `[1, 2, 3].each { puts it }` works, `posts.each { puts its.title }` should work too. -- https://bugs.ruby-lang.org/
participants (4)
-
duerst
-
Earlopain (Earlopain _)
-
matz (Yukihiro Matsumoto)
-
northeastprince (Matt Almeida)