Project

General

Profile

Actions

Feature #15741

closed

Ordinal parameters

Added by mame (Yusuke Endoh) about 3 years ago. Updated about 3 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
[ruby-core:92067]

Description

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) ordinal-parameters.patch mame (Yusuke Endoh), 03/31/2019 11:52 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #12240: circle number argumentsRejectedActions
Actions

Also available in: Atom PDF