On Saturday, September 03, 2016 14:42:34 Cauterite via Digitalmars-d wrote: > On Saturday, 3 September 2016 at 14:25:49 UTC, rikki cattermole > > wrote: > > I propose a slight change: > > do(x, y, return z) > > Hmm, I suppose I should mention one other motivation behind this > DIP: > > I really like to avoid using the 'return' keyword inside > expressions, because I find it visually confusing - hear me out > here - > When you're reading a function and trying to understand its > control flow, one of the main elements you're searching for is > all the places the function can return from. > If the code has a lot of anonymous functions with return > statements this can really slow down the process as you have to > more carefully inspect every return to see if it's a 'real' > return or inside an anonymous function. > > Also, in case it wasn't obvious, the do() syntax was inspired by > Clojure: > http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/do
So, instead of having the return statement which everyone knows to look for and is easy to grep for, you want to add a way to return _without_ a return statement? That's just _begging_ for trouble IMHO. There's no question that it will be confusing, and unless you have a ton of anonymous functions or nested functions returning within a function (which most D code doesn't), then I don't see how there's any question that it's worse. And since most D code doesn't have a lot of nested constructs with a function which have return statements, it seems to me that we're really just making it harder for most programmers to find all of the return statements within a function. - Jonathan M Davis
