Open mellonpizza opened 2 months ago
isn't that the assert command?
assert 2+2 == 4, "your math sucks"
asar's functions are (currently) eagerly evaluated. even the ternary function evaluates all arguments first. this is why we needed to add safediv(). this might be changing in 2.0, but definitely not before that
oh right, you're writing a function. can't put asserts in that
we could add an assert() function, though
and what do you propose its signature is? assert(condition, error_message, value_if_no_error)? that looks janky, and then the value branch needs to also not throw any errors if the condition isn't fulfilled...
I've encountered situations where I'd like to create a function but it requires certain invariants to be upheld in the arguments, or else the output would be undefined and it would make most sense to throw an error, but there is currently no way to do this. I figure a reasonable solution would be to add an
error()
function which functionally can be identical to theerror
directive, with 1 string argument.