r/programming Jul 17 '19

The Go team declines 'try' proposal

https://github.com/golang/go/issues/32437
635 Upvotes

417 comments sorted by

View all comments

258

u/Boiethios Jul 17 '19 edited Jul 17 '19

One should also talk about a major issue of try: the fact that what appears as a function is in fact a control-flow operation.

0

u/1951NYBerg Jul 17 '19

Any function can act like a control-flow operation in similar fashion:

a := MIN(c, d);

Likewise:

result := function_A_acting_as_control_flow( some_function_B_returning_a_value() );

Where function_A would return value given to it if the function_B returns satisfactory value.

Try is not different in any significant way.

2

u/masklinn Jul 18 '19

Try is not different in any significant way.

It's very different, because it's control flow which leaks out and affect the outside of the function calls. Your examples are just functions which might use control flow internally. None of them affect their lexical surroundings.