[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]
Check out Janggi (Korean Chess), our featured variant for December, 2024.
Check out Janggi (Korean Chess), our featured variant for December, 2024.
I made a change to the following functions that can run lambda functions on array values: aggregate, allfalse, nonetrue, alltrue, anyfalse, anytrue, any. These will now have access to the variable
key
, which will contain the key of the array value currently passed to the lambda function. This should be accessed with thevar
keyword to make sure that a previously defined variable is not being used.To prevent expressions using these from changing the value of a previous variable called
key
, I had to raise the scope of every expression. But to get this to work, I had to rewrite each built-in function that exited the PHP function for evaluating expressions with areturn
. Instead of usingreturn
, I had each one set$output
to a single element array with the return value, and I set$input
to an empty array so that the condition on the while loop would be false. Doing this makes sure that it decrements the scope before exiting the function.Raising the scope of an expression also makes sure that the mechanism for adding named variables to a function cannot be used in an expression to set a variable that lasts beyond the expression. The following code prints 6468, then it prints 63. This is because it raises the scope for the assignments in the expression, and when it completes the expression, it closes that scope.