On Wednesday, 10 October 2018 at 08:46:42 UTC, James Japherson wrote:
Would be nice to be able to pass $ as a function argument to be used in automatic path length traversing.

void foo(int loc)
{
   return bar[loc];
}

then foo($) would essentilly become

foo(&)

  becomes ==>

   return bar[$];


instead of having do to thinks like foo(bar.length).

The usefulness comes from the case when bar is local:

void foo(int loc)
{
   auto bar = double[RandomPInt+1];

   return bar[loc];
}


then foo($) always returns a value and the outside world does not need to know about foo. Since $ is a compile thing expression and not used anywhere else this can always be done(it is a symbolic substitution and has a direct translation in to standard D code except $ cannot be used as arguments like this the current D language grammar).

I don't really get your example and what benefits this would have?

And also what about the current behavior of the $ operator?

Reply via email to