From: shevegen@... Date: 2019-04-01T07:59:32+00:00 Subject: [ruby-core:92084] [Ruby trunk Feature#15741] Ordinal parameters Issue #15741 has been updated by shevegen (Robert A. Heiler). Check the date sawa. :) The thing is, though ... if we ignore the date (and I guess nobu is having fun since it may seem less obvious if mame creates the issue ;) ) ... actually I did want to propose adding .second .third and so forth, since we have .first and .last already. The reason why was mostly for code like this: some_array = [] # it gets filled with stuff person_name = some_array.first person_height = some_array[1] person_age = some_array.last Now for the moment let's ignore that a Hash would be better for this, it is just meant for illustration purpose. My argument would be that [1] looks strange when I already use .first and .last, so I wanted to use .second instead. However had ... my use case is not that good nonetheless. It's just mostly a visual thing ... when I use [0], [1], [2] then this looks fine; and when I use .first and .last this looks fine too. It only looked strange when I would mix both. Another problem was that, for example, how often would people use something like .fifth? Or .sixth? Probably not that often. So I sort of abandoned that ideal for a proposal. I did, however had, also want to suggest another one on this first april, aka to suggest a compiled variant of ruby. And while 95% of this would have been meant as a joke, 5% would have been serious. I twould not have to be ruby exactly, but just a compiled language, a bit like the ruby-crystal situation (but matz would design it; but no worries, even in my joke suggestion, I would not suggest that matz would IMPLEMENT it - it was only meant for the design stage). And probably a full alternative to C too. One reason here was that many casual or less formal users do not know C yet the really cool things all seem to happen in/through C. ---------------------------------------- Feature #15741: Ordinal parameters https://bugs.ruby-lang.org/issues/15741#change-77415 * Author: mame (Yusuke Endoh) * Status: Open * Priority: Normal * Assignee: * Target version: Next Major ---------------------------------------- Numbered parameters have been introduced into trunk, and are still being hotly debated in #15723. One of the problems of the feature is, too short, too symbolic, and then too cryptic. It resembles Perl. I counterpropose "ordinal parameters": ``` $ ./miniruby -e ' [ [1, 1, 1], [2, 2, 2], [3, 3, 3] ].each { p 0th * 1st * 2rd } ' 1 8 27 ``` Ordinal parameters are much better than numbered parameters in two points: * It is English. No symbol is used. It looks nicer, doesn't it? * Some people are complaining that `@1` is one-based. Instead, my proposal is zero-based: it starts with `0th`. In other words, it no longer resembles the notorious `$1` at all. You may wonder if it is too friendly for English speakers. Don't worry, it is carefully designed: * It is tolerant of small errors. In fact, "2rd" (not "2nd") is allowed. This is because I often typo. * Even "1th", "2th", and "3th" are allowed. Non-English-native programmers don't have to learn the difference among "st", "nd", "rd", and "th". A patch is attached. ---Files-------------------------------- ordinal-parameters.patch (1.62 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: