what's the semantics of 'varX is varY', in particular `strX is strY`?

mw mingwu at gmail.com
Wed Aug 5 17:29:09 UTC 2020


I've thought it's compare by reference, as in e.g. `assert(obj 
!is null)`

but

```
   string strX = "2020-07-29";
   string strY = "2020-07-29";
   string strZ = "2020-07-30";
   assert(strX !is strY);  // assertion failed
   assert(strX !is strZ);  // assertion pass
```

so here `is` means compare strings by their contents? where is 
the exact definition of the  semantics of 'varX is varY'?


BTW, on page:

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

`is` directly link to:

https://dlang.org/spec/expression.html#IsExpression

which only talks about is(expr), not 'varX is varY'


Thanks.



More information about the Digitalmars-d mailing list