I would like to write int(x > y). The go compiler states that it cannot convert x > y (type bool) to type int. Sure the language specification doesn't support it, but I wonder why this is the case. I understand that Go doesn't support implicit type conversions and I'm fine with that.The explicit conversion would be well defined: false will be 0 and true will be 1. There is even a mathematical notation for it: [x > y]. Graham, Knuth and Patashnik call it Iverson convention in "Concrete Mathematics" stating that Kenneth A. Iverson introduced it in his programming language APL. Sure you can implement your own Iverson function, but 6g doesn't do any optimization on it, so there is a real price to pay here. C doesn't have the issue because all operators returning Boolean values have type int by definition and implicit conversion of the _Bool type is supported.Currently I'm using my own Iverson() function, because I have functions returning bool that need to be used as int in a specific context. From my viewpoint that is the typical use case for an explicit conversion.
Can you give an example of its use in a case where boolean operators are not sufficient?