ruby picture

RCR 316: arguments after a splat in a method call

Submitted by eric_mahurin (Sun Sep 11 18:55:46 UTC 2005)

Abstract

The restriction that no arguments or splats follow a splat when calling a method should be removed. The same can be said of the multiple-assign RHS.

Problem

Many times, you'll want to splat some array in an argument list into its components. This need may or may not correlate to where a splatted (or maybe unsplatted?) argument is in the method definition. Currently, if you want to do something like this:

a,b,*c,d,*f,g

you have to do this:

a,b,*(c+[d]+f+[g])

Proposal

A calling argument list or RHS of a multiple-assign like this:

a, *b, c, d, *e, f

should be equivalent to:

*([a]+b+[c]+[d]+e+[f])

Basically, form an array by concatenating arguments as elements (not splatted) or as arrays (splatted). Then splat the whole thing as the argument list.

Analysis

The current limitation that no arguments are allowed after a splatted argument within an argument list seems quite arbitrary.

No backwards incompatibilities.

I just found that this legacy RCR is almost identical:

https://rcrchive.net/rcr/show/115

Implementation

A parser change and more continuity in how calling argument lists (and MRHS) are handled.
ruby picture
Comments Current voting
Accepted. You will see this in Ruby2.

-matz.


Strongly opposed 0
Opposed 0
Neutral 0
In favor 1
Strongly advocate 1
ruby picture
If you have registered at RCRchive, you may now sign in below. If you have not registered, you may sign up for a username and password. Registering enables you to submit new RCRs, and vote and leave comments on existing RCRs.
Your username:
Your password:

ruby picture

Powered by .