3 ms·
As primarily a Python programmer with some C++ in my background, Whiley is a fascinating mixture of the familiar and the unfamiliar. The indentation-based block
by andrewflnr 15y ago
As primarily a Python programmer with some C++ in my background, Whiley is a fascinating mixture of the familiar and the unfamiliar. The indentation-based blocks are from Python, the function type syntax is like C++, among other ways I would feel at home. But then it throws in ~= as an instanceof operator, and has weird (for me) mutability and object models. Altogether, just having read a lot of the language guide, I could see myself programming something in it tomorrow, given some more research.
- redjamjar 15y agoHey, 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 ...