On Wednesday, 15 August 2018 at 14:58:40 UTC, Everlast wrote:
Many times one must create a variable before a function call:


  int x = 3;
  foo(x);
  writeln(x);

and this is fraught with problems such as dependencies(move or change the second line and one has to validate how the first line is affected along with all the others).

A new an improved technique, which consolidates the two lines in to one is to automatically have the compiler define the variable:

foo(x = 3);
writeln(x); // x was implicitly created in this scope by foo.

Couldn't you do what you need to do with UFCS and possibly a tee function if you need to add things like writeln into the chain that don't pass the data on?

Reply via email to