On Wednesday, 10 October 2018 at 23:04:46 UTC, James Japherson
wrote:
The whole point is not to use $ as an identifier but to specify
to the compiler of that it can rewrite it.
It's called 'alias'.
// compile time
int foo(alias index)(int[] a)
{
return a[index(a.length)];
}
// run time
int barr(int[] a, size_t function(size_t) index)
{
return a[index(a.length)];
}
int main()
{
import std.range: iota;
import std.array: array;
import std.stdio: writeln;
int[100] a = iota(0,100).array;
a.foo!(l => l-3).writeln;
a.barr(l => l-3).writeln;
return 0;
}