Lua is good at domain-specific languages. There's no reason we should preprocess source code.
Instead of:
e2function number operator==(complex lhs, complex rhs)
if abs(lhs[1] - rhs[1]) > delta then return 0 end
if abs(lhs[2] - rhs[2]) > delta then return 0 end
return 1
end
We could get away with:
e2function [[number operator==(complex, complex)]] ..
function(lhs, rhs)
if abs(lhs[1] - rhs[1]) > delta then return 0 end
if abs(lhs[2] - rhs[2]) > delta then return 0 end
return 1
end
And that's valid pure Lua.
It's not quite as nice a syntax, I grant you that, but it would actually work correctly with code editors, and it would get rid of a significant amount of code. We could also use the same syntax for registerType / registerOperator, which currently use pure Lua to define their E2 names and types.
Lua is good at domain-specific languages. There's no reason we should preprocess source code.
Instead of:
We could get away with:
And that's valid pure Lua.
It's not quite as nice a syntax, I grant you that, but it would actually work correctly with code editors, and it would get rid of a significant amount of code. We could also use the same syntax for
registerType/registerOperator, which currently use pure Lua to define their E2 names and types.