Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upResult value design (`err(x)/ok(x)`) #82
Comments
bvssvni
added
draft
information
labels
Mar 19, 2016
bvssvni
removed
the
draft
label
Mar 31, 2016
bvssvni
closed this
Mar 31, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bvssvni commentedMar 19, 2016
•
edited
Dyon uses a separate dynamic type for result values. The result type has two variants,
errandok. It has a lot of common with option value, but there are a few differences.err(x)creates an error with messagex, using deep cloneok(x)creates a successful result with valuex, using deep cloneunwrap(x)unwraps a result type, when error prints error message plus?trace messagesunwrap_err(x)unwraps error messageis_err(x)returnstrueif result is an errorFor both result and option, the
?operator propagates the error (requires->on function):x?,x.a?,x[0]?.b.c?etc.foo()?or following after any expressionWhen a the value is
none()orerr(x), the?operator propagates the error. Returns from the function. A trace message is added to help debugging onunwrap, describing where the?operation happened.some(x)is converted took(x).This is designed for: