More operators inside `is(...)` expressions
Stefan Koch
uplink.coder at googlemail.com
Mon Aug 24 12:28:27 UTC 2020
On Monday, 24 August 2020 at 11:49:05 UTC, Steven Schveighoffer
wrote:
> On 8/24/20 4:03 AM, Timon Gehr wrote:
>> On 23.08.20 23:08, Per Nordlöw wrote:
>>> Why aren't more operators allowed inside
>>> `is(...)`-expressions?
>>>
>>> For instance
>>>
>>> if (!is(CommonType!(typeof(min), typeof(max)) == void))
>>>
>>> could be written as
>>>
>>> if (is(CommonType!(typeof(min), typeof(max)) != void))
>>>
>>> .
>>
>> So is(undefined != void) would be `true`? (Where `undefined`
>> does not exist.)
>
> Yes. If you write !is(T == void), then you are already not
> checking whether T is defined. This is no different.
>
> This literally is just a nicer way to write it, where the
> operation is closer to the parameters, instead of partly
> outside the expression.
>
> -Steve
The problems I see here are:
1) Complicating the rules for is expressions further
2) Adding a special syntax for what I perceive to be an uncommon
case
I.E. (T != void) does not narrow your result set significantly.
The only place where you could write that is if your T-set is
already narrowed down.
Or rather if you have a (T == void) specialization which you want
to rule out.
I might be wrong here but I do think that's uncommon.
More information about the Digitalmars-d
mailing list