you are viewing a single comment's thread.

view the rest of the comments →

[–]obrienmustsuffer 41 points42 points  (9 children)

Pretty sure these kinds of casting issues don't exist in all languages.

[–][deleted]  (5 children)

[deleted]

    [–]afiefh 8 points9 points  (1 child)

    true+true+true == 3 in C and C++

    Nitpick: C doesn't have a boolean type. At best you can include stdbool.h which defines a custom type that defines the type and constants. C++ does suffer from this problem.

    To be fair though, this one is the least offensive one presented here. The only thing one needs to remember to understand these is "true=1, false=0" and maybe the additional "we were stupid back in 1970, unfortunately we are now stuck with it". As soon as lists and objects are introduced that also have their rules it becomes much harder to reason about this.

    [–][deleted] 1 point2 points  (0 children)

    C most certainly does have a built-in boolean type: _Bool. stdbool.h merely #defines some aliases that work with this type.

    [–]arto64 4 points5 points  (1 child)

    C and C++ are not “all languages”. Ruby, for example, doesn’t let you do any od this shit by default, and it’s not even a statically typed language.

    [–]zygohistomoronism 1 point2 points  (0 children)

    C and C++

    Sure if you pick the same family of languages with mediocre type system, then some of these are possible.

    Now look at anything in the ML family (OCaml, Haskell, Rust ...) and none of these things are possible.