Hello Philippe,

Hello,

some time ago, chris (ruunhb) posted something on his Dspec project,
where he used a template syntax I didn't know:

----
void each(alias array, T : T[] = typeof(array))(void delegate(T item)
dg) {
foreach(T i; array)
dg(i);
}
int[] array = [1, 2, 3, 4];
int b = 10;
each!(array) = (int item) {
writefln("%d", item + b);
};
---
I'm intrigued by the last lines. I'd have thought 'each' to be invoked
by:

each!(array)( (int item) {writefln("%d", item+b)} );


What that is, is the property syntax. I places where there is a function named foo that takes one arg, it can be called by "foo = arg;"

But this doesn't work. And I never encountered Chris' syntax before:

I'm not sure why the normal syntax wouldn't work.

--
... <IXOYE><



Reply via email to