Reading TDPL on functions and delegated literals (5.6.1)
auto f = (int i) {}; assert(is(f == function));
I have an approval error. Is this statement correct?
I tried the following:
int z = 5; auto f = (int i) { return i < 5; }; auto d = (int i) { return i < z; }; assert(is(typeof(f) == typeof(d)));
The statement is really there. In fact, f is a delegate, not a function, even if it does not need a frame pointer to access local variables. This is mistake?
Also, I don't understand how assert(is(f == function)); must work.
I tried assert(is(f == delegate)); but this also failed. What's wrong?
I am using the DMD32 D v2.053 compiler
UPDATE
auto f = (int i) {}; assert(is(typeof(f) == delegate))
It works correctly, although there is no reason to be a delegate
But
auto f = function (int i) {}; assert(is(typeof(f) == void function(int))); // correct assert(is(typeof(f) == function)); // failed!!!!!
Miracle It seems D2 is not yet ready for production.
Stas
source share