I'd rather do it in the language instead of in script, because you may
still care about the difference between nil and not having passed a
parameter at all.
Well, you can always switch to a different dialect ;) (I've used the 'puzzlement command' ?que to dump out the actual generated Lua)
$ mooni MoonScript version 0.2.3 Note: use backslash at line end to start a block
> f = (x,y=2) -> print x,y > ?que f = function(x, y) if y == nil then y = 2 end return print(x, y) end
> f 10
10 2
Moonscript has become the happy home of many language proposals from lua-l, but this is not a criticism of Lua's minimalism, which generally is a good thing (I only miss short-function forms really)
Although (more seriously) is that important to have this sugar? Surely it is a documentation issue? E.g. LDoc supports this style of annotation: