8
\$\begingroup\$

On the default allowed I/O methods, we have come to a consensus that programs may not take input from a predefined variable.

However, we have decided that anonymous functions are allowed. In the answer, the poster, arguing that it doesn't make sense to ban anonymous functions, says, "it wastes bytes on something rather arbitrary.

Assume that this was a Javascript solution:

s=x=>x+1

By that argument, we could remove the s= from the beginning, leaving this:

x=>x+1

This means that it can't just be used as a full program by itself, but it is still allowed.

Here's the problem: By our current rules, this would be disallowed:

x+1

This is taking input from a predefined variable. Arguably, however, the anonymous function header x=> is also wasting bytes on something arbitrary. The new snippet can't be used on its own, but that's true for the anonymous function as well. It's just a matter of whether you declare the input variable in the program or not.

I understand that this is a slippery slope, but I still think this problem lacks a justified solution.

Why should taking input from a predefined variable be disallowed?

\$\endgroup\$
  • 7
    \$\begingroup\$ You don't have to save an anonymous function in a variable to use it; (x=>x+1)(1) and [1,2,3].map(x=>x+1) works just fine on their own. In fact, it's not even the intended use case. If you're going to name your function, might might as well use a function expression. \$\endgroup\$ – Dennis Feb 3 '17 at 4:38
  • \$\begingroup\$ @Dennis That's true, but the program by itself cannot be simply run. Arguably you don't have to save the other one either: x=1,x+1 \$\endgroup\$ – Esolanging Fruit Feb 3 '17 at 4:51
  • \$\begingroup\$ It's not allowed because the community decided that we didn't want to allow it. Since (currently) 27 people have voted that it's not allowed, and they voted for their own reasons, this question is too broad IMO. \$\endgroup\$ – Mego Feb 3 '17 at 5:20
  • 1
    \$\begingroup\$ The header of an anonymous function is basically what makes it a function. x=> defines an anonymous function with an input that will be referenced as x inside it. Then, x does not refer to the variable x, but to the function's input x. You can't do (x+1)(1), since x+1 is a snippet that returns the sum of the variable x and the literal 1. As that is an integer literal and not a function literal, it is not callable as a function. On the contrary, (x=>x+1)(1) works because x=>x+1 is a function literal that, when you call it, will calculate the sum of x (its input) and 1. \$\endgroup\$ – Erik the Outgolfer Feb 3 '17 at 13:46
  • \$\begingroup\$ I'm voting to close as a dupe of ^ because that's the post for suggesting input formats. If you don't like this being disallowed, go vote there. \$\endgroup\$ – Rɪᴋᴇʀ Feb 3 '17 at 22:42
  • 2
    \$\begingroup\$ I'm voting to reopen as discussions for justifying a certain policy seems to be explicitly on topic. A meta question regarding site policy is better discussed in this format than the comment or vote section on a post. \$\endgroup\$ – Rohan Jhunjhunwala Feb 5 '17 at 1:40