2 ms·
From the docs, the prefix %return is a shortcut for: const number = parseU64(str, 10) %% |err| return err; Keeping the %% syntax, how about: const number
by iainmerrick 9y ago
From the docs, the prefix %return is a shortcut for:
const number = parseU64(str, 10) %% |err| return err;
Keeping the %% syntax, how about:
const number = parseU64(str, 10) %% throw;
(Or "raise" maybe)
I think that ordering is more readable than having the %return tucked away in the middle of the line (even more so if it becomes a plain keyword, no % sign).
Edit to add: a "throw" keyword could also be used to shorten normal error returns too:
return error.InvalidChar;
Becomes:
throw InvalidChar;