Re:Go makes it easier to write correct, clear and efficient ...
by skybrian on Friday May 10, 2019 @11:03AM
(#19878444)
Hmm, I've never heard anyone else object to mid-function returns. Usually guard clauses are considered a good thing. What's your objection to them?
[ Parent
| on HN ]
Re:Go makes it easier to write correct, clear and efficient ...
by jeswin on Friday May 10, 2019 @12:55PM
(#19879686)
I'm increasingly used to everything (including entire function bodies) being expressions. It's very much a personal preference though.
Re:Go makes it easier to write correct, clear and efficient ...
by jayd16 on Friday May 10, 2019 @11:23AM
(#19878619)
Like GOTO it makes the execution harder to reason about as you could easily miss it. It doesn't bother me personally but I can sort of see an argument for it.
Re:Go makes it easier to write correct, clear and efficient ...
by icholy on Friday May 10, 2019 @12:29PM
(#19879357)
Avoiding early returns usually makes code harder to read. It's outdated advice which was meant for writing assembly.
Re:Go makes it easier to write correct, clear and efficient ...
by apta on Friday May 10, 2019 @03:50PM
(#19881602)
It's not outdated, it depends on context. Several modern languages, including Rust, Swift, Scala, Kotlin, and F# are built around having expressions as constructs (if, match, try, etc. are all expressions). Once you have that powerful feature it makes sense to write code in a certain way to make use of that, and it ends up being clearer a lot of the time.