Those are used for IO or user signaling, not error reporting (that's the process's return status, stderr may be used to augment it with a cause, unix utilities are centered about the status signaling correct/incorrect execution).
> I think, a function/call get a value or a exception, so why not be more explicit about that?
It's fine to be explicit about it (again that's what Rust does), the problem is your example isn't really explicit about it, and the second sample is downright weird. It's like Go except even more screwy.
edit: in an other subthread you mention following dynamically typed languages, if we go with that and assume no type support it makes slightly more sense, but the logic is still screwy: assuming the second snippet is a function which doesn't have a result (so it can only have an error) it should use the same system as the third snippet, the faulting assignment (first snippet) is the one which should use a different syntax.
And then there'a the question of what semantics you get when not assigning but just nesting expressions.
An option might be to attach the decision to the call instead (kinda like Swift) e.g. the result of a regular function call would be either `error` or `result, error` (with the language enforcing that one of result and error must be nil) but by "banging" the function the error is raised instead of returned. So you'd get something along the lines of:
# no result, possibly an error
err = foo()
# a result or an error
result, err = foo()
# no result, panics in case of error
!foo()
# a result or panics in case of error
result = !foo()
the language would enforce that either the error fetched or the function is bang-ed, so
foo()
would be illegal, because it neither receives the error nor raises on error.
Yep, as I have think, is more or less like you say.
>if we go with that and assume no type support
Wonder why is harder with a type system (I say follow the syntax, not the type system of julia/python... so I wanna be as static as possible, or at least try)
Ok, was a big mistake to show the idea with this on-the-fly-invented syntax this way (because: I still not settle on it), I just try to convey the idea not the implementation.
I wanna build a F#-like type-system with sum/products (https://www.reddit.com/r/fsharp/comments/30ywjy/question_how...) for my language, and be the result of the function already a Result<T, E>, without the user need to annotate it manually. So, I'm thinking in the kind of development that happened in reactive library but as a intrinsic model of the language.
Of course, I'm a total noob in this area, so still researching about this!
Is modeled like unix IO (with stdin/out/err). Anyway, I think, a function/call get a value or a exception, so why not be more explicit about that?