Describe the bug
I want to sort a list of items using the sort() function. To improve the readability of the expression, I want to define the sorting function before, inside the same context.
But it doesn't work and the sort() function returns null.
If I inline the sorting function then it works as expected.
{
sorted: sort(items, function (x,y) x.prio < y.prio)
}
Note that this is a general issue that the function definition can not be accessed as a variable. But it can be invoked as a function.
{
greeting: function (x) "Hello " + string(x),
test: greeting("FEEL")
}
// works: "Hello FEEL"
{
greeting: function (x) "Hello " + string(x),
test: greeting instance of function
}
// failed to evaluate expression '{
// greeting: function (x) "Hello " + string(x),
// test: greeting instance of function
// }': no variable found for name 'greeting'
Describe the bug I want to sort a list of items using the
sort()
function. To improve the readability of the expression, I want to define the sorting function before, inside the same context.But it doesn't work and the
sort()
function returnsnull
.If I inline the sorting function then it works as expected.
Note that this is a general issue that the function definition can not be accessed as a variable. But it can be invoked as a function.
To Reproduce Steps to reproduce the behavior:
With the context:
null
Expected behavior I can pass a reference to a function definition as a function argument to the
sort()
function.In general, I can access a reference to a function definition, for example, to check that the type of the reference is a function.
Environment