Passing $ as a function argument
James Japherson
JJ at goolooking.com
Wed Oct 10 08:46:42 UTC 2018
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).
More information about the Digitalmars-d
mailing list