DIP1001: DoExpression

Cauterite via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 3 07:42:34 PDT 2016


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


More information about the Digitalmars-d mailing list