On 23-Oct-06, at 1:11 PM, Asko Kauppi wrote:
The issue is, in larger programs its really benefitial to have the
_option_ of using type constraints on your variables, values, and
return values. Doing them integrated with the syntax simply hides
them more from the eye than doing 'assert' everywhere.
But why hide them? assert is a perfectly good way of making it
clear what the function expects:
function extract(str, i, j)
assert(isString(str))
assert(isNumber(i) and i > 0 and i <= #str)
assert(isNumber(j) and j >= i and j <= #str)
local outside = str:sub(1, i) .. str:sub(j+1)
local inside = str:sub(i, j)
assert(#outside + #inside == #str)
return inside, outside
end