The issue is that Lua treats functions as "first-class," meaning that they are stored in variables like other data. This is how named functions are created within the language, and function syntax is sugar for initializing a variable and stuffing a function into it.
This works with API functions also, which is why this works.
This works with API functions also, which is why this works.