Re: assert-like debug { /* code */ } feature?
Tegiri Nenashi wrote:
On Sep 5, 1:40 pm, Eric Sosman <esos...@ieee-dot-org.invalid> wrote:
Because the type of `x = true' is boolean, while the
type of `y = 1' is int.
Here is the essence of our disagreement. Contrary to what gospel
(sorry, JLS) may insist, assignment is not a variable. It is a way to
apply changes to the state of the world. Therefore, assignment doesn't
have a type.
It's not a variable. Plenty of non-variable things have types. 5 is not
variable, yet it clearly has a type of |int|. Things that have types are
called `expressions', and assignments are expressions in MANY languages,
including (but not limited to):
* Awk
* C
* C++
* Java
* Javascript (sorry, ECMAScript)
* Python
* PHP
In fact variables (or the values thereof, to be precise) are themselves
expressions.
Would you like citations from ISO C++ and other language specs, or are
these explanations sufficient?
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth