Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
design/32437-try-builtin.md: adjustment to
try
signature
The proposal defines `try` as a built-in taking n+1 arguments and returning n results. It relies on the "usual" assignment rules which make it possible to call `try` with a multi-valued function call as argument. The proposal also suggests that if need be, `try` may be "easily" extended to take an addition argument such as a handler. This is not possible with the current signature as was pointed out by Andrew Ekstedt (https://github.com/magical) in the discussion of the corresponding issue (#32437). This change modifies `try` such that it accepts a single, possibly multi-valued expression as argument instead. Because only a single argument is expected now, it's easy to extend `try` to accept an optional 2nd argument in the future, if so desired. This change has no substantial impact on this proposal. It does make it impossible to use `try` with more than one explicitly provided incoming arguments, such as in x, y, z := try(a, b, c, err) but such code is mostly pathological and can always be rewritten using `if` statements if necessary. Change-Id: I687e0e1ab63328c1b381715cee7f77fdfac45b67 Reviewed-on: https://go-review.googlesource.com/c/proposal/+/181878 Reviewed-by: Ian Lance Taylor <iant@golang.org>
- Loading branch information