Re:Zig: a system language which prioritizes optimality, safe...
by pmontra on Monday August 29, 2016 @06:17AM
(#12380995)
Agreed, %return is confusing and sends the reader down a wrong path.
Your last example could work if error is the default name for the error variable, which makes sense.
http://andrewkelley.me/post/intro-to-zig.html shows the
pattern and then goes on to say that you can avoid repeating "%% |err| return err" all the time by writing instead. I don't think that's particularly nice; it looks too much like "return the result of the call" when that's only what happens in the error case. I would have expected something more like this: where the compiler would turn "return error" into "|_some_var| return _some_var".