On Sunday, February 18, 2018 at 12:47:09 AM UTC-7, Krzysztof Kowalczyk
wrote:
>
> Even simpler:
>
> r, err := try os.Open("blah.text")
>
> Similar to Swift and what Rust used to have.
>
> "try foo()" means: if "foo()" returns an error, return the error to the
> caller.
> If function returns mul
Even simpler:
r, err := try os.Open("blah.text")
Similar to Swift and what Rust used to have.
"try foo()" means: if "foo()" returns an error, return the error to the
caller.
If function returns multiple values, it would return zero value for
non-error values.
I believe now Rust has the follow
I think for me the benefit of a new statement is that it doesn't result in
changes to existing formatting/behaviour. Rather it provides a familiar
syntax and style semantic and results in no change to an existing code base
(e.g. it's opt in).
The problems I see with allowing 1 liner conditionals a
The notion of "return X if Y" is fun...it means I'm waking up to SNOBOL in
2018. Fantastic flashback but awkward here.
Changing formatting to allow single line "if X { trivial Y }" seems natural.
On Sat, Feb 17, 2018 at 6:05 AM, wrote:
> The OP's idea is the best one so far. What about the foll
The OP's idea is the best one so far. What about the following.
r, err := os.Open("blah.txt")
*return* nil *if* r == nil, err *if* err != nil
basically every return field could be followed by an optional if clause
with an expression that must evaluate to bool.
The return only happens if all opt
Or just change how gofmt formats if statements where the block is a single
return statement.
if r, err := os.Open( "blah.text"); err != nil { return nil, err }
Or if parseable:
return r, err if { r, err := os.Open( "blah.txt" ) ; err != nil }
I think the first is better, but I'm happy with Go
Ah, I just re-read the thread subject: if *any* of the values are non-nil.
Sorry for the misunderstanding.
On Friday, February 16, 2018 at 3:42:23 PM UTC-7, Paul Brousseau wrote:
>
> If all of the values are non-nil, then `retnn nil, err` would not return,
> would it? Did I miss something?
>
>
If all of the values are non-nil, then `retnn nil, err` would not return,
would it? Did I miss something?
On Friday, February 16, 2018 at 2:38:05 PM UTC-7, Nathan Fisher wrote:
>
> Hi All,
>
> I've been contemplating alternative methods to address the "boiler plate"
> of error handling in Go. O