3 ms·
Hey, So, what do you think would be better than "~="? (that's a genuine question since the syntax is not locked down yet by any means). I thought about "isa"
by redjamjar 15y ago
Hey,
So, what do you think would be better than "~="? (that's a genuine question since the syntax is not locked down yet by any means). I thought about "isa", also "<:" (following academic papers) and, of course, plain old "instanceof". But, the latter is too much finger typing for me ...
Oh, and of course we could do something like "typeof(x) == int" etc
- andrewflnr 15y agoOff the top of my head, a simple "is" would be nice. Pronounceable and short.
- munificent 15y agoIt's what C# uses too. Seems to work well.
- redjamjar 15y agoahh, that's interesting I didn't realise that!!
- kiwidrew 15y agoI rather like how Go decided to handle this, using "type switches": switch x := node.(type) { case Node: // x is of type Node in this block case Leaf: // x is of type Leaf in this block } (http://golang.org/doc/go_spec.html#Type_switches http://golang.org/doc/go_spec.html#Type_switches)
- redjamjar 15y agoSo whilst it doesn't work yet, I actually will support type switches as well ...