On Friday, 20 October 2017 at 23:01:25 UTC, Steven Schveighoffer wrote:
On 10/20/17 6:23 PM, Patrick wrote:
On Friday, 20 October 2017 at 22:15:36 UTC, Steven Schveighoffer wrote:
On 10/20/17 5:55 PM, Patrick wrote:
Due to the very specific nature of the 'is' operator, why wouldn't the compiler know to implicitly query the class types? Why must it be explicitly written, typeof(this)?

The compiler generally doesn't "fix" errors for you, it tells you there is a problem, and then you have to fix it. You have to be clear and unambiguous to the compiler. Otherwise debugging would be hell.

Not asking the compiler to fix my errors.

When would
is(this, myClass) not mean: is(typeof(this) : typeof(myClass))?

class C
{
}

int c;

C myC;

is(myC : c);

oops, forgot to capitalize. But compiler says "I know, you really meant is(typeof(myC) : typeof(c)) -> false.

-Steve

If I explicitly wrote: is(typeof(myC) : typeof(c)) the outcome would still be false and it would still require debugging. So your example demonstrates nothing other then a type-o was made. Try again...

In this unique case, the compiler should identify the class and primitive types are incompatible and should issue an error instead (and not return false).

Patrick

Reply via email to