Sam Huwrote:
Q4.In the delegate somFnExp:front(),popFront,empty() are all not defined??Anyway it is not an interface ,so why it is allowed?
Basically, is(typeof(X)) is D magic. One could interpret it as 'is X a valid type', or perhaps more correctly as 'does X compile'. So if SomeFnExp does something it is not allowed to (e.g. call popFront on something that has no popFront), it will return false. If I were to write this code without is(typeof()) around it: R r; if (r.empty) {} r.popFront; auto h = r.front; It might seem a strange piece of code, but there is nothing inherently wrong with it. empty, popFront and front are expected members of R, and will give a compilation error if R does not follow the interface (note: not as in a D interface, but as in exposing the correct functions to the outside world). -- Simen