'is(T==return)' How does is expression with return keyword as TypeSpecialization

Alex sascha.orlov at gmail.com
Thu Jul 5 11:21:41 UTC 2018


On Thursday, 5 July 2018 at 10:32:01 UTC, Timoses wrote:
>     int fun(T)(T i)
>     {
>         static assert(is(typeof(return) == T)); //true
>         pragma(msg, is(T == return)); // false
>         static if (is(T ReturnType == return))
>             pragma(msg, ReturnType); // does not enter
>         return i;
>     }
>     unittest
>     {
>         fun(3);
>     }
>
> What's the purpose of 'is(T == return)' if not the above?

I always thought that "return" is a keyword.

https://dlang.org/spec/lex.html#keywords

And the fact, that you can ask the keyword about its type is just 
a nice feature... ;)


More information about the Digitalmars-d-learn mailing list