[DIP idea] out variables

Tobias Pankrath tobias+dlang at pankrath.net
Tue Jan 26 10:26:20 UTC 2021


On Tuesday, 26 January 2021 at 01:01:54 UTC, Q. Schroll wrote:
> In-place `out` Variables
> ========================
>
> When calling a function with an `out` parameter, instead of 
> passing an argument, a fresh variable can be declared instead:
>
>     if (f(out int x) > 0 && x > 0) { g(x); } else { .. }
>     if (g(0) && f(out x) > 0) { g(x); } else { .. }
>

I recently started using C# professionally which has this feature 
already. It makes function with out parameters so much more 
pleasant to use.

Many argue that we should not overload D with even more features, 
but I'd say, if it makes D more fun to use and it is just syntax 
sugar / a simple lowering than we should consider it.


More information about the Digitalmars-d mailing list