Literals in Programming Languages
gavilan.edu
gavilan.edu
http://www.franz.com/support/documentation/6.2/ansicl/subsec...
Isn't it strange to compare Python/Perl to C and say that one is better than the other? It's apples to oranges. You wouldn't use Python or Perl to build an OS, and you wouldn't use C to prototype a web app.
It mentions array literals: http://www.gavilan.edu/csis/languages/literals.html#_Toc7587...
(int []) { 1, 2, 3 }
(struct Point) { 3, 5 }
(struct Point) { .x = 3, .y = 5 }I was surprised to find this is true,
You could choose to ignore that partial ordering at your own peril.
(they might as well have been added by a user library).
(In Haskell, it's just sugar for negate 14, while in Standard ML it's spelt ~14. And I assume there are other exceptions too.)
Not really. It's done in java. Usually, minus ("-") is parsed as a token and then unary minus on integer literals are transformed to a negative integer literal.
So, -2147483648 is read as MINUS INT_LITERAL and thus transformed into "-2147483648" as an INT_LITERAL, but -(2147483648) should be read as MINUS L_PAREN INT_LITERAL R_PAREN and should thus not be transformed.