'is(T==return)' How does is expression with return keyword as TypeSpecialization
Timoses
timosesu at gmail.com
Thu Jul 5 11:37:16 UTC 2018
On Thursday, 5 July 2018 at 11:21:41 UTC, Alex wrote:
> 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... ;)
I think it refers to this section:
https://dlang.org/spec/expression.html#is_expression
I don't remember where I read this usage (think it was in a
book), but I noted it down and now I wonder how it can be used.
More information about the Digitalmars-d-learn
mailing list