DIP1001: DoExpression

rikki cattermole via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 3 07:47:50 PDT 2016


On 04/09/2016 2:42 AM, Cauterite 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

I may dislike not using return but please consider at the very least 
using ; instead of , for the last element do(x, y ; z). Just something 
to hint that the last one is special.

Truth be told I don't want to be spending time figuring out syntax at 
e.g. 3am which is not core to D or c like languages.


More information about the Digitalmars-d mailing list