Content: Issue with "Rest parameters": …

Created on 30 Dec 2020  Â·  9Comments  Â·  Source: mdn/content

MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters

What information was incorrect, unhelpful, or incomplete?

The original meaning of "Rest" makes sense, but it would be nice if a more technical/consistent term was used. I suggest Left Variadic Parameters or Left Variadic Function Parameters

Specific section or headline?

The name of the Article is the Issue

What did you expect to see?

Left Variadic Parameter/Rest Parameters

Did you test this? If so, how?

It's just copy, so I used my eyes.



MDN Content page report details

question

All 9 comments

The spec calls them “rest parameters”:

https://tc39.es/ecma262/#sec-algorithm-conventions

A rest parameter may appear at the end of a parameter list, denoted with leading ellipsis (, ..._name_). The rest parameter captures all of the arguments provided following the required and optional parameters into a List.

So it seems good to try align with the same terminology the spec actually uses. Or not?

Could you elaborate on the rationale for using different terminology for this than what the spec uses?

Did a quick search.
Seems that _variadic_ is the function and not the arguments.

http://raganwald.com/2015/04/03/left-variadic.html

Screenshot_20201230-194649.png

Left Variadic Parameters or Left Variadic Function Parameters

Rest parameters are "right variadic" (additional arguments to into the right-most parameter), not "left variadic", though.

Left Variadic Parameters or Left Variadic Function Parameters

Rest parameters are "right variadic" (additional arguments to into the right-most parameter), not "left variadic", though.

function (a, ...b, c) {}

This is _center variadic_? We need 3 pages?

_right-most_ means left?

Oops, I definitely meant Right Variadic. My bad folks!

The only reason I mentioned it is because I was googling Variadic Functions in JavaScript and I ignored the "Rest Parameter" result because I assumed it was off-topic and unhelpful. I agree "Rest" parameter is in line with the Spec and is descriptive, but I don't see the terminology used as commonly as variadic. I just wanted to help people realize that "Rest Parameters" aren't to be confused with "RESTful" topics and are related to the variadic topic.

I really don't have a specific solution to this. Just thought it could use some improvement via a discussion.

I just wanted to help people realize that "Rest Parameters" aren't to be confused with "RESTful" topics and are related to the variadic topic.

Agreed, having the article provide clarification on those two points would be useful. So I opened https://github.com/mdn/content/pull/818 with a patch that adds some clarifying language.

In my understanding, a variadic function is a function, that accepts an arbitrary amount of arguments. (You can use it with JavaScript's arguments, too).

A rest parameter is an argument to a function, that „collects all remaining arguments” (after the positional arguments were assigned).

I'd consider it two different things.

The note about „right variadic” might be helpful (although it's more relevant to Function Programming developers).

Resolved by #818

Was this page helpful?
0 / 5 - 0 ratings