Explain function syntax
Ali Çehreli
acehreli at yahoo.com
Fri Sep 19 16:58:38 UTC 2025
On 9/18/25 10:18 PM, Steven Schveighoffer wrote:
> On Thursday, 18 September 2025 at 18:10:13 UTC, Ali Çehreli wrote:
>> // Not a delegate:
>> static assert(is (typeof(twice) == function));
> You are mistaking the is expression for a function test with the
> function pointer type.
I disagree because it is impossible to mistake much from the
documentation of the is expression:
https://dlang.org/spec/expression.html#is_expression
I stress strongly that there is not enough information there to take
anything incorrectly. The reader has to construct a consistent mental
model from that documentation. I did and my mental model is intact.
I did test with 'function' against 'delegate' and it worked as I still
understand it. For the example I wrote, 'is' expression succeeds for
'function' but not for 'delegate' if the nested function makes use of
local scope.
Ali
More information about the Digitalmars-d-learn
mailing list