www.digitalmars.com         C & C++   DMDScript  

D - bit != bool

reply "Jeroen van Bemmel" <anonymous somewhere.com> writes:
Just to start a discussion

IMO bit and bool are not synonymous. 'bit' refers to storage size, whereas
'bool' refers to semantics. 'bit' is more restrictive, and can be used to
implement a boolean variable.

In relationship with the thread on structs vs. classes: I could imagine that
a class has 'bool' variables, which the compiler is free to move around and
where the programmer doesn't really care too much if it takes 1 bit or 8 bit
(for more efficient access perhaps). 'bit' on the contrary is very specific
about this, I would be surprised if my compiler used 8 bits to store my
bit...
Jan 27 2003
parent reply Burton Radons <loth users.sourceforge.net> writes:
Jeroen van Bemmel wrote:
 IMO bit and bool are not synonymous. 'bit' refers to storage size, whereas
 'bool' refers to semantics. 'bit' is more restrictive, and can be used to
 implement a boolean variable.
D's bit has semantics identical to proper bool; it wasn't a misnomer when it was introduced, but it is now. The name should be changed, Walter knows the problem, let's never mention it again.
Jan 27 2003
parent reply Mark T <Mark_member pathlink.com> writes:
In article <b13pgl$28lp$1 digitaldaemon.com>, Burton Radons says...
Jeroen van Bemmel wrote:
 IMO bit and bool are not synonymous. 'bit' refers to storage size, whereas
 'bool' refers to semantics. 'bit' is more restrictive, and can be used to
 implement a boolean variable.
D's bit has semantics identical to proper bool; it wasn't a misnomer when it was introduced, but it is now. The name should be changed, Walter knows the problem, let's never mention it again.
Will the "bit" name ever go away and be replaced by "bool" or "Boolean" or will it be like pre-ISO C99 where everyone invents a new name for Booleans? Once a lot of code gets written one way then the language is almost forced to carry that style forward, example: K&R C idioms like defaulting to int return type had to be allowed in ISO C90, finally dumped in C99.
Feb 09 2003
parent reply Ilya Minkov <midiclub 8ung.at> writes:
Why? I like the name. It's short. Cubistic. Minimalistic. Doesn't 
pretent to be more important than it is. And versatile. I don't see why 
some people can't just get used to calling bool a bit? Why has bit to go 
away? What would you prefer: to have a bitarray (what it always is), or 
a boolarray (sometimes a lie)? A bitarray might be a flag array, but it 
generally needn't. And how about bitstreams vs. boolstreams?


Mark T wrote:
 Will the "bit" name ever go away and be replaced by "bool" or "Boolean" or will
 it be like pre-ISO C99 where everyone invents a new name for Booleans? 
 
 Once a lot of code gets written one way then the language is almost forced to
 carry that style forward,  example: K&R C idioms like defaulting to int return
 type had to be allowed in ISO C90, finally dumped in C99.
 
Feb 09 2003
parent "Mike Wynn" <mike.wynn l8night.co.uk> writes:
"Ilya Minkov" <midiclub 8ung.at> wrote in message
news:b25rbm$2a1v$1 digitaldaemon.com...
 Why? I like the name. It's short. Cubistic. Minimalistic. Doesn't
 pretent to be more important than it is. And versatile. I don't see why
 some people can't just get used to calling bool a bit? Why has bit to go
 away? What would you prefer: to have a bitarray (what it always is), or
 a boolarray (sometimes a lie)? A bitarray might be a flag array, but it
 generally needn't. And how about bitstreams vs. boolstreams?
bit is storage, bool is semantics; a bool array _might_ be implemented as a bit array, but could be char or int per bool a bit array / stream is bits. bits currently can not be passed by reference, you require a pointer to the byte/int + shift however a bool could be, because it is valid to store a bool in an int to pass to/from func and bit within a local/member.
 Mark T wrote:
 Will the "bit" name ever go away and be replaced by "bool" or "Boolean"
or will
 it be like pre-ISO C99 where everyone invents a new name for Booleans?

 Once a lot of code gets written one way then the language is almost
forced to
 carry that style forward,  example: K&R C idioms like defaulting to int
return
 type had to be allowed in ISO C90, finally dumped in C99.
Feb 09 2003