Is Boolean a Built-in Enum in C? -
i wondering if boolean built-in enumeration. according wikipedia ~
"some enumerator types may built language. boolean type, example pre-defined enumeration of values false , true."
http://en.wikipedia.org/wiki/enumerated_type
in c , other languages, boolean enum? , if not - can explain why?
the question more of abstract, philosophical question "what type" c. in c, (more or less) integer @ heart, misses point.
when "integer" referring arithmetic type, i.e. 1 arithmetic operations addition , multiplication make sense.
by contrast, enumerative type type holds collection of discrete values have no further structure among them. property enumerative value has itself; there no operations on other checking equality.
forgetfully, integers enumerative type (they enumerate number of shoes can have on shoe rack, sizes of herds of sheep), there's more them - have internal structure given arithmetic operations admit.
a boolean value can considered enumerative type forgetting operations, , considering enumerates 2 states, true , false. however, booleans have whole set of operations defined on them, given logical operations (and, or, not, etc.), makes them different plain enums. in sense, booleans closer "one-bit integers" "enums".
in summary, every discrete type can thought of enum (and handles identically hardware), enums "weakest" of discrete types, having no structure beyond identity. contrast, integers , booleans discrete types additional (respectively arithmetic , logical) structure.
Comments
Post a Comment