D - No out bit parameters
- Frank Wills (11/11) Aug 03 2003 No out bit parameters: I can work
- Ilya Minkov (9/12) Aug 03 2003 I believe it is because a pointer to bit has not been implemented yet,
- Frank Wills (3/22) Aug 03 2003 Actually, my workaround is to use a pointer
- Walter (3/7) Aug 03 2003 Yes, that is a good idea.
- Frank Wills (3/15) Aug 03 2003 Walter, any chance you will answer my question, or
- Walter (5/15) Aug 03 2003 The trouble comes from the out parameter being one bit out of an array o...
- Frank Wills (6/11) Aug 03 2003 Ok, thanks. I was just curious as to why it was that way, and also
- Frank Wills (4/23) Aug 03 2003 Why do you say "obviously" it is not required as an out
- Mike Wynn (16/27) Aug 03 2003 which bit is the bit ?
- Frank Wills (25/60) Aug 03 2003 Mike,
- Matthew Wilson (9/69) Aug 03 2003 Wearing my heretical pragmatist hat, may I pose the question: why do we ...
- Burton Radons (4/7) Aug 03 2003 Its semantics are for boolean. It should be renamed - I want "boolean",...
- Matthew Wilson (23/30) Aug 03 2003 have
- Riccardo De Agostini (11/18) Aug 04 2003 expression
- Walter (8/15) Aug 04 2003 have
- Mike Wynn (17/32) Aug 04 2003 we
- Burton Radons (3/27) Aug 04 2003 "boolean" describes its semantics without bringing in either unfortunate...
- Walter (5/11) Aug 04 2003 "bool" is
- BenjiSmith (20/31) Aug 04 2003 I think that a 'bit' gives the impression that it will always be impleme...
- Walter (23/42) Aug 04 2003 implemented as
- Derek Parnell (15/66) Aug 04 2003 Its a conceptual thing mainly. A 'bool' is a STATE but a 'bit' holds a d...
- Sean L. Palmer (20/33) Aug 08 2003 data
- Mark T (10/13) Aug 05 2003 sorry, to embedded folks that's a little confusing. we want a bit to be ...
- Walter (11/26) Aug 05 2003 the
- Mark Evans (8/11) Aug 06 2003 Oh my goodness - those are one of the major bug nests in embedded work. ...
- Sean L. Palmer (9/12) Aug 08 2003 FPGA
- Sean L. Palmer (13/18) Aug 08 2003 Of
- Burton Radons (11/28) Aug 04 2003 It gives the impression that it has "bit" semantics! A bit is an
- Walter (9/37) Aug 05 2003 as
- Mike Wynn (5/13) Aug 05 2003 but what about the other way ?
- Walter (5/18) Aug 05 2003 purposes.
- Burton Radons (4/55) Aug 05 2003 That it can be forced to behave similar to a bit using a lot of casting
- Walter (4/6) Aug 07 2003 All it would be is:
- Burton Radons (3/12) Aug 08 2003 That it can be forced to behave similar to a bit using a lot of casting
- Matthew Wilson (3/15) Aug 08 2003 I'm with you, my bold bool brother
- Walter (5/14) Aug 09 2003 I disagree with the assessment that it's a lot of casting and support co...
- Mark T (3/3) Aug 05 2003 after a quick google search found this interesting piece on C and Ada bi...
- Bill Cox (6/25) Aug 06 2003 Hi, Walter.
-
Walter
(3/6)
Aug 07 2003
I think you might be the only one happy with that besides myself
. - Sean L. Palmer (18/29) Aug 08 2003 as
- Walter (3/6) Aug 09 2003 It's implemented in 0.69.
- Frank Wills (11/23) Aug 06 2003 I guess I'm lazy, because I like bool better than
- Matthew Wilson (10/33) Aug 06 2003 than
- Mike Wynn (12/15) Aug 07 2003 I disagree with the latter part of that.
- Mark T (4/20) Aug 08 2003 I agree with this and many others do also (why does Walter fight this??...
- Peter Hercek (8/11) Aug 10 2003 If bits are not going to be usable as out parameters, then we definitely...
- Mike Wynn (13/25) Aug 10 2003 news:bgsml6$2cu1$1@digitaldaemon.com...
- Matthew Wilson (9/36) Aug 10 2003 not
- Peter Hercek (7/11) Aug 10 2003 Why it should be int and not 8bit quantity? Sorry, I do not want to poke...
- Mike Wynn (22/37) Aug 11 2003 news:bh6va4$2rfm$1@digitaldaemon.com...
- Matthew Wilson (26/41) Aug 11 2003 1. Efficiency ... mostly. However, I recognise that int is not the most
- Sean L. Palmer (11/15) Aug 11 2003 What we'd all like to have is a choice between a fast bool and a small b...
- Matthew Wilson (4/20) Aug 11 2003 Now you're talking! ;)
- Sean L. Palmer (14/26) Aug 11 2003 Well if the compiler can do bit*, it should be able to do out bit. Ther...
- Mike Wynn (25/32) Aug 04 2003 I appologise, just giving what I could remember from the answer I got fr...
No out bit parameters: I can work around this, but I was curious about the reason. Is it just technical? I like to have certain functions return a bit value for success or failure, and use an out parameter to return results. bit someFunc(out char[] result) but bit someFunc(out bit result) isn't allowed.
Aug 03 2003
Frank Wills wrote:No out bit parameters: I can work around this, but I was curious about the reason. Is it just technical?I believe it is because a pointer to bit has not been implemented yet, which would need an adress, as well as an offset within a byte. Obviusly, it is not requiered for an out parameter... Walter: how about allowing pointer to bit in an abridged form? It can currently be a simple byte pointer, which you get when taking adress of a bit, but when the bit is not lowest within a byte, it should raise an exception, signalling that it's not implemented yet. -i.
Aug 03 2003
Actually, my workaround is to use a pointer to a bit as the parameter, which works fine. Ilya Minkov wrote:Frank Wills wrote:No out bit parameters: I can work around this, but I was curious about the reason. Is it just technical?I believe it is because a pointer to bit has not been implemented yet, which would need an adress, as well as an offset within a byte. Obviusly, it is not requiered for an out parameter... Walter: how about allowing pointer to bit in an abridged form? It can currently be a simple byte pointer, which you get when taking adress of a bit, but when the bit is not lowest within a byte, it should raise an exception, signalling that it's not implemented yet. -i.
Aug 03 2003
"Ilya Minkov" <midiclub 8ung.at> wrote in message news:bgjbv6$2ll9$1 digitaldaemon.com...Walter: how about allowing pointer to bit in an abridged form? It can currently be a simple byte pointer, which you get when taking adress of a bit, but when the bit is not lowest within a byte, it should raise an exception, signalling that it's not implemented yet.Yes, that is a good idea.
Aug 03 2003
Walter wrote:"Ilya Minkov" <midiclub 8ung.at> wrote in message news:bgjbv6$2ll9$1 digitaldaemon.com...Walter, any chance you will answer my question, or is the answer too "obvious" to answer?Walter: how about allowing pointer to bit in an abridged form? It can currently be a simple byte pointer, which you get when taking adress of a bit, but when the bit is not lowest within a byte, it should raise an exception, signalling that it's not implemented yet.Yes, that is a good idea.
Aug 03 2003
"Frank Wills" <fdwills sandarh.com> wrote in message news:bgjlhl$2ts2$1 digitaldaemon.com...Walter wrote:The trouble comes from the out parameter being one bit out of an array of bits. Then, a simple pointer will no longer suffice, it needs a pointer and a bit number. It's not impossible, just some more work to implement."Ilya Minkov" <midiclub 8ung.at> wrote in message news:bgjbv6$2ll9$1 digitaldaemon.com...Walter, any chance you will answer my question, or is the answer too "obvious" to answer?Walter: how about allowing pointer to bit in an abridged form? It can currently be a simple byte pointer, which you get when taking adress of a bit, but when the bit is not lowest within a byte, it should raise an exception, signalling that it's not implemented yet.Yes, that is a good idea.
Aug 03 2003
Walter wrote:The trouble comes from the out parameter being one bit out of an array of bits. Then, a simple pointer will no longer suffice, it needs a pointer and a bit number. It's not impossible, just some more work to implement.Ok, thanks. I was just curious as to why it was that way, and also trying to help by providing feedback. I don't know if you intended bit pointers to be used, or to work at this point, but they do, and that is what I am using until the bit type is usable with an out parameter, which is more elegant to use that pointers.
Aug 03 2003
Ilya Minkov wrote:Frank Wills wrote:Why do you say "obviously" it is not required as an out parameter? I don't see anything "obvious" about what you say at all.No out bit parameters: I can work around this, but I was curious about the reason. Is it just technical?I believe it is because a pointer to bit has not been implemented yet, which would need an adress, as well as an offset within a byte. Obviusly, it is not requiered for an out parameter...Walter: how about allowing pointer to bit in an abridged form? It can currently be a simple byte pointer, which you get when taking adress of a bit, but when the bit is not lowest within a byte, it should raise an exception, signalling that it's not implemented yet. -i.
Aug 03 2003
which bit is the bit ? consider; void func( out bit rv, int i ) { ... } void meth() { bit a,b, c; func(a, 0 );func(b, 3 );func(c, 6 ); } a,b,c might be bits 0,1,2 of the first stack word shift and mask to the in is always bit0 is o.k. but you either have to pass the ptr to the storage word/dword and the position to save to or have copy on return (which might mess up some code). I believe there is no bit* which would be struct ( int pos, int * storePtr; } similar to array. "Frank Wills" <fdwills sandarh.com> wrote in message news:bgiv3n$2ati$1 digitaldaemon.com...No out bit parameters: I can work around this, but I was curious about the reason. Is it just technical? I like to have certain functions return a bit value for success or failure, and use an out parameter to return results. bit someFunc(out char[] result) but bit someFunc(out bit result) isn't allowed.
Aug 03 2003
Mike, Sure, sure, yes, yes, I imagine that most people on this list understand everything you are explaining, and the issues involved (who on this list doesn't know what a bit is, and that it is a part of a larger addressable unit in memory?) I just wanted to know (from Walter): 1) Why "out" isn't currently implemented for bit parameters. 1 - Walter's answer) It sounds like it will or could be, if and when he gets to it. And that there's just more work to implementing the bit type in various manners. Obviously there are no 'bit' addressable memory units in memory, it must be 'extracted' from larger units (I'm not telling anyone anything new here am I?) 2) Bit pointers __do__ currently work. Does Walter __intend__ for them to work, or are they just happening to work. 2 - Walter's answer) It sounds like he may do something to better refine the use of bit pointers. I don't yet know if he intended for them to work at this point at all. Mike Wynn wrote:which bit is the bit ? consider; void func( out bit rv, int i ) { ... } void meth() { bit a,b, c; func(a, 0 );func(b, 3 );func(c, 6 ); } a,b,c might be bits 0,1,2 of the first stack word shift and mask to the in is always bit0 is o.k. but you either have to pass the ptr to the storage word/dword and the position to save to or have copy on return (which might mess up some code). I believe there is no bit* which would be struct ( int pos, int * storePtr; } similar to array. "Frank Wills" <fdwills sandarh.com> wrote in message news:bgiv3n$2ati$1 digitaldaemon.com...No out bit parameters: I can work around this, but I was curious about the reason. Is it just technical? I like to have certain functions return a bit value for success or failure, and use an out parameter to return results. bit someFunc(out char[] result) but bit someFunc(out bit result) isn't allowed.
Aug 03 2003
Wearing my heretical pragmatist hat, may I pose the question: why do we have a bit type? I am at a loss to think why it is useful (or more useful than bit fields). I'll concede that I've not done any comms programming for some time, so maybe the "totally bleeding obvious" reason has slipped my memory. Yours, ready to be informed Matthew "Frank Wills" <fdwills sandarh.com> wrote in message news:bgk5n1$bs2$1 digitaldaemon.com...Mike, Sure, sure, yes, yes, I imagine that most people on this list understand everything you are explaining, and the issues involved (who on this list doesn't know what a bit is, and that it is a part of a larger addressable unit in memory?) I just wanted to know (from Walter): 1) Why "out" isn't currently implemented for bit parameters. 1 - Walter's answer) It sounds like it will or could be, if and when he gets to it. And that there's just more work to implementing the bit type in various manners. Obviously there are no 'bit' addressable memory units in memory, it must be 'extracted' from larger units (I'm not telling anyone anything new here am I?) 2) Bit pointers __do__ currently work. Does Walter __intend__ for them to work, or are they just happening to work. 2 - Walter's answer) It sounds like he may do something to better refine the use of bit pointers. I don't yet know if he intended for them to work at this point at all. Mike Wynn wrote:which bit is the bit ? consider; void func( out bit rv, int i ) { ... } void meth() { bit a,b, c; func(a, 0 );func(b, 3 );func(c, 6 ); } a,b,c might be bits 0,1,2 of the first stack word shift and mask to the in is always bit0 is o.k. but you either have to pass the ptr to the storage word/dword and the position to save to or have copy on return (which might mess up some code). I believe there is no bit* which would be struct ( int pos, int * storePtr; } similar to array. "Frank Wills" <fdwills sandarh.com> wrote in message news:bgiv3n$2ati$1 digitaldaemon.com...No out bit parameters: I can work around this, but I was curious about the reason. Is it just technical? I like to have certain functions return a bit value for success or failure, and use an out parameter to return results. bit someFunc(out char[] result) but bit someFunc(out bit result) isn't allowed.
Aug 03 2003
Matthew Wilson wrote:Wearing my heretical pragmatist hat, may I pose the question: why do we have a bit type? I am at a loss to think why it is useful (or more useful than bit fields).Its semantics are for boolean. It should be renamed - I want "boolean", as "bool" is just lazy. Walter, is there any reason why it hasn't been renamed?
Aug 03 2003
"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgkdol$ish$1 digitaldaemon.com...Matthew Wilson wrote:haveWearing my heretical pragmatist hat, may I pose the question: why do wethana bit type? I am at a loss to think why it is useful (or more usefulI could not agree more. It should be called boolean, it should not be a bit, it should be the same size as int, and any writing of the literal 'true' in (sub-)expressions should be automatically translated by the compiler to the inverse expression involving 'false', thereby avoiding the potential dangers of tri-state bool in C++. Furthermore, (now you've got me going!), all conditional (sub-)expression should have to be _explicitly_ boolean. Hence boolean b; int i; if( b && i) // compiler error {} if( b && i != 0) // ok {} But I realise that all the obfuscators will *never* swallow that one, so just give me the first paragraph of requirements above, and I'll be quiet. Matthewbit fields).Its semantics are for boolean. It should be renamed - I want "boolean", as "bool" is just lazy. Walter, is there any reason why it hasn't been renamed?
Aug 03 2003
"Matthew Wilson" <matthew stlsoft.org> ha scritto nel messaggio news:bgkeft$jk9$1 digitaldaemon.com...It should be called boolean, it should not be a bit, it should be the same size as int, and any writing of the literal 'true' in (sub-)expressions should be automatically translated by the compiler to the inverseexpressioninvolving 'false', thereby avoiding the potential dangers of tri-stateboolin C++.Maybe it could be a "real" bit when it's an element in an array. Once you have the starting address and index, automatic bit masking is not that hard to implement. Besides, why not make it 1 byte in size, or at least have a compiler option which lets you do it?Furthermore, (now you've got me going!), all conditional (sub-)expression should have to be _explicitly_ boolean. [...]I see the point. That's going to be a hard battle though... Ric
Aug 04 2003
"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgkdol$ish$1 digitaldaemon.com...Matthew Wilson wrote:haveWearing my heretical pragmatist hat, may I pose the question: why do wethana bit type? I am at a loss to think why it is useful (or more usefulI've put a bool alias for bit in 0.69. I found "bit" to be appealing, as there is the implication that there is none of this tri-state confusion nonsense we find in C, but others obviously don't see it that way. "bool" is used in C and C++.bit fields).Its semantics are for boolean. It should be renamed - I want "boolean", as "bool" is just lazy. Walter, is there any reason why it hasn't been renamed?
Aug 04 2003
"Walter" <walter digitalmars.com> wrote in message news:bglv4d$1vvn$2 digitaldaemon.com..."Burton Radons" <loth users.sourceforge.net> wrote in message news:bgkdol$ish$1 digitaldaemon.com...weMatthew Wilson wrote:Wearing my heretical pragmatist hat, may I pose the question: why dohaveisthana bit type? I am at a loss to think why it is useful (or more usefulI've put a bool alias for bit in 0.69. I found "bit" to be appealing, as there is the implication that there is none of this tri-state confusion nonsense we find in C, but others obviously don't see it that way. "bool"bit fields).Its semantics are for boolean. It should be renamed - I want "boolean", as "bool" is just lazy. Walter, is there any reason why it hasn't been renamed?used in C and C++.the C bool as an alias to int is poor (again its implementation over symantics) the Java boolean is what we want (I do): storage and implementation are undefined only the semantics are defined. it can be only true or false, and if cast to a numeric value then false === 0 true === 1 (like C where !!int is 0 or 1 ) to cast a pointer or reference (object or array) to boolean is equiv to b = (o === null) ? false : true; all compare ops return they type boolean not bit. I've no objection to bit and bit[] (although think if you have them then they should be complete [that is int to bit array and bit array slice to int operations, along with inout, out and pointer to bit]) I have the same "problem" with char/wchar[] as strings to me string is a concept and char[] implementation.
Aug 04 2003
Walter wrote:"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgkdol$ish$1 digitaldaemon.com..."boolean" describes its semantics without bringing in either unfortunate comparisons (bool, Windows' BOOL) or completely wrong impressions (bit).Matthew Wilson wrote:haveWearing my heretical pragmatist hat, may I pose the question: why do wethana bit type? I am at a loss to think why it is useful (or more usefulI've put a bool alias for bit in 0.69. I found "bit" to be appealing, as there is the implication that there is none of this tri-state confusion nonsense we find in C, but others obviously don't see it that way. "bool" is used in C and C++.bit fields).Its semantics are for boolean. It should be renamed - I want "boolean", as "bool" is just lazy. Walter, is there any reason why it hasn't been renamed?
Aug 04 2003
"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgmfml$2fr1$1 digitaldaemon.com..."bool" isI've put a bool alias for bit in 0.69. I found "bit" to be appealing, as there is the implication that there is none of this tri-state confusion nonsense we find in C, but others obviously don't see it that way.What wrong impression does bit give? I'm a bit (!) flummoxed as to why people find bit so distasteful.used in C and C++."boolean" describes its semantics without bringing in either unfortunate comparisons (bool, Windows' BOOL) or completely wrong impressions (bit).
Aug 04 2003
I think that a 'bit' gives the impression that it will always be implemented as one element of an eight-element byte. That's the impression that I get from using a 'bit'. I don't know if that's how it's implemented in DMD, but that's how I think of it: as a tiny unit of memory. Now, a 'boolean' is not a unit of memory as all. It's a semantic term given to a true/false condition. I don't care how a boolean is implemented, as long as it has two-and-only-two values: true and false, and as long as it provides me a mechanism for flipping between the two values. If you're a compiler vendor (and you are), I don't care whether you implement the boolean primitive type as a bit or as an 8-bit type, if that makes addressing and dereferencing more efficient. Let the compiler do whatever it wants with boolean types as long as I can get sizeof(boolean) to know how many bits (or bytes) are taken up by the type. However, if I call sizeof(bit), it should be exactly the same on every platform (.125). I don't know if anybody else is on the same page as me, but these are the reasons that I'd like to have a boolean type instead of just a bit type. Of course, I'd like to have _both_ bits and booleans (please just don't call it 'bool'), since bits (and bit arrays) could be useful for their own purposes. But I'd prefer to keep my true/false values in a boolean than in a bit. In article <bgmnb5$2n2b$1 digitaldaemon.com>, Walter says..."Burton Radons" <loth users.sourceforge.net> wrote in message news:bgmfml$2fr1$1 digitaldaemon.com..."bool" isI've put a bool alias for bit in 0.69. I found "bit" to be appealing, as there is the implication that there is none of this tri-state confusion nonsense we find in C, but others obviously don't see it that way.What wrong impression does bit give? I'm a bit (!) flummoxed as to why people find bit so distasteful.used in C and C++."boolean" describes its semantics without bringing in either unfortunate comparisons (bool, Windows' BOOL) or completely wrong impressions (bit).
Aug 04 2003
"BenjiSmith" <BenjiSmith_member pathlink.com> wrote in message news:bgmpoe$2ph4$1 digitaldaemon.com...I think that a 'bit' gives the impression that it will always beimplemented asone element of an eight-element byte. That's the impression that I getfromusing a 'bit'. I don't know if that's how it's implemented in DMD, butthat'show I think of it: as a tiny unit of memory.'bit' is one bit, although it may be in a byte as the (lonely) bit 0 and the rest of the byte is unused.Now, a 'boolean' is not a unit of memory as all. It's a semantic termgiven to atrue/false condition. I don't care how a boolean is implemented, as longas ithas two-and-only-two values: true and false, and as long as it provides meamechanism for flipping between the two values.'bit' does that.If you're a compiler vendor (and you are), I don't care whether youimplementthe boolean primitive type as a bit or as an 8-bit type, if that makes addressing and dereferencing more efficient. Let the compiler do whateveritwants with boolean types as long as I can get sizeof(boolean) to know howmanybits (or bytes) are taken up by the type. However, if I call sizeof(bit),itshould be exactly the same on every platform (.125).'bit' does that, too. bit.size will give (1), because unless it is an array of bits, it is put into a byte.I don't know if anybody else is on the same page as me, but these are the reasons that I'd like to have a boolean type instead of just a bit type.Ofcourse, I'd like to have _both_ bits and booleans (please just don't callit'bool'), since bits (and bit arrays) could be useful for their ownpurposes. ButI'd prefer to keep my true/false values in a boolean than in a bit.I just fail to see what improvement boolean has over bit. Also, what's wrong with 'bool'? It fits with the C'ish convention of using 'int' instead of 'integer', 'float' instead of 'floatingpointreal', etc.
Aug 04 2003
On Mon, 4 Aug 2003 18:34:51 -0700 (08/05/03 11:34:51) , Walter <walter digitalmars.com> wrote:"BenjiSmith" <BenjiSmith_member pathlink.com> wrote in message news:bgmpoe$2ph4$1 digitaldaemon.com...Its a conceptual thing mainly. A 'bool' is a STATE but a 'bit' holds a data value. A 'bit' must be mapped to a RAM location but a 'bool' doesn't (I'm not talking about implementatin here - just logical/conceptual stuff). Conceptually, you can do arithmetic with bits but it doesn't make sense to add up three 'bools', for example. When it comes to implementing a bool, you would probably wise to choose a data storage element that is fast - such as an int. However, you might serious consider disallowing arithmetic functionality, include comparisions to numeric values. It doesn't make much sense if test if a 'bool' is larger than 5, for example. As you mention above, a 'bit' can be used to implement a 'bool'. However, a 'bit' has more functionality behind it than a 'bool' needs or even wants. -- DerekI think that a 'bit' gives the impression that it will always beimplemented asone element of an eight-element byte. That's the impression that I getfromusing a 'bit'. I don't know if that's how it's implemented in DMD, butthat'show I think of it: as a tiny unit of memory.'bit' is one bit, although it may be in a byte as the (lonely) bit 0 and the rest of the byte is unused.Now, a 'boolean' is not a unit of memory as all. It's a semantic termgiven to atrue/false condition. I don't care how a boolean is implemented, as longas ithas two-and-only-two values: true and false, and as long as it provides meamechanism for flipping between the two values.'bit' does that.If you're a compiler vendor (and you are), I don't care whether youimplementthe boolean primitive type as a bit or as an 8-bit type, if that makes addressing and dereferencing more efficient. Let the compiler do whateveritwants with boolean types as long as I can get sizeof(boolean) to know howmanybits (or bytes) are taken up by the type. However, if I call sizeof(bit) ,itshould be exactly the same on every platform (.125).'bit' does that, too. bit.size will give (1), because unless it is an array of bits, it is put into a byte.I don't know if anybody else is on the same page as me, but these are the reasons that I'd like to have a boolean type instead of just a bit type.Ofcourse, I'd like to have _both_ bits and booleans (please just don't callit'bool'), since bits (and bit arrays) could be useful for their ownpurposes. ButI'd prefer to keep my true/false values in a boolean than in a bit.I just fail to see what improvement boolean has over bit. Also, what's wrong with 'bool'? It fits with the C'ish convention of using 'int' instead of 'integer', 'float' instead of 'floatingpointreal', etc.
Aug 04 2003
"Derek Parnell" <derek.parnell no.spam> wrote in message news:oprtesn7jf59ej19 news.digitalmars.com...Its a conceptual thing mainly. A 'bool' is a STATE but a 'bit' holds adatavalue. A 'bit' must be mapped to a RAM location but a 'bool' doesn't (I'm not talking about implementatin here - just logical/conceptual stuff).That's just not true. There is nothing that says a bit has to be in a memory location: It could just as easily dwell in a register or even in a CPU flag, if only transiently.Conceptually, you can do arithmetic with bits but it doesn't make sense to add up three 'bools', for example.True enough, the operators that apply to bool are different than the ones that apply to bit. Logical ops could apply to both. Seems the main difference is that bit is compatible mathematically with integers, and bool is not. However if you think about it, AND is alot like multiply or minimum, OR is alot like maximum, XOR is alot like addition or subtraction. One could define operations that make sense on both. It would take great care to do so, however, and probably people would end up confused.When it comes to implementing a bool, you would probably wise to choose a data storage element that is fast - such as an int. However, you might serious consider disallowing arithmetic functionality, includecomparisionsto numeric values. It doesn't make much sense if test if a 'bool' islargerthan 5, for example. As you mention above, a 'bit' can be used to implement a 'bool'. However,a'bit' has more functionality behind it than a 'bool' needs or evenwants. --DerekYep, that pretty much sums it up. Sean
Aug 08 2003
In article <bgn1bu$30od$1 digitaldaemon.com>, Walter says...sorry, to embedded folks that's a little confusing. we want a bit to be one part of a register or memory location which may be combined together in contiguous but odd or even sizes (the hardware guys never like to waste bits by padding out) to control all sorts of stuff. 0 5 12 31 | field_1 | field_2 | field_3 | If D is supposed to be a systems programming language than it shouldn't confuse the hardware engineers who create the FPGAs which in turn are manipulated by the embedded SW folks.how I think of it: as a tiny unit of memory.'bit' is one bit, although it may be in a byte as the (lonely) bit 0 and the rest of the byte is unused.
Aug 05 2003
"Mark T" <Mark_member pathlink.com> wrote in message news:bgo4e1$111h$1 digitaldaemon.com...In article <bgn1bu$30od$1 digitaldaemon.com>, Walter says...thehow I think of it: as a tiny unit of memory.'bit' is one bit, although it may be in a byte as the (lonely) bit 0 andone partrest of the byte is unused.sorry, to embedded folks that's a little confusing. we want a bit to beof a register or memory location which may be combined together incontiguousbut odd or even sizes (the hardware guys never like to waste bits bypaddingout) to control all sorts of stuff. 0 5 12 31 | field_1 | field_2 | field_3 | If D is supposed to be a systems programming language than it shouldn'tconfusethe hardware engineers who create the FPGAs which in turn are manipulatedby theembedded SW folks.I've actually done code dealing with such issues (and I've even written FPGA design tools), and I find it works best to simply write the shift and mask operations custom to the job.
Aug 05 2003
Walter wroteI've actually done code dealing with such issues (and I've even written FPGA design tools), and I find it works best to simply write the shift and mask operations custom to the job.Oh my goodness - those are one of the major bug nests in embedded work. How nice it would be to just 'slice' a bit array instead. About the boolean type I would not mind its absence if D were not a DbC language. But in such a language, the missing boolean type is like a missing thumb. Since DbC is built into the language, booleans should be built into it as well - they go together. C/C++ doesn't have DbC so it's a different story. Mark
Aug 06 2003
"Walter" <walter digitalmars.com> wrote in message news:bgpbmc$29go$1 digitaldaemon.com...I've actually done code dealing with such issues (and I've even writtenFPGAdesign tools), and I find it works best to simply write the shift and mask operations custom to the job.Please. You should know better than anyone that a compiler is far more suited to that task than any person. It's tedious, error-prone grunt work, and nobody should have to do that anymore. It's 2003, not 1970. ;) Besides, explicit bit masking is *UGLY*, and deserves to be hidden behind the scenes. Sean
Aug 08 2003
"BenjiSmith" <BenjiSmith_member pathlink.com> wrote in message news:bgmpoe$2ph4$1 digitaldaemon.com...I don't know if anybody else is on the same page as me, but these are the reasons that I'd like to have a boolean type instead of just a bit type.Ofcourse, I'd like to have _both_ bits and booleans (please just don't callit'bool'), since bits (and bit arrays) could be useful for their ownpurposes. ButI'd prefer to keep my true/false values in a boolean than in a bit.FWIW, I prefer the shortened name 'bool'. For one thing, that's what C and C++ people will expect, and what they're used to. Gives D a bit more compatibility with those languages. It's the same reason we don't write out 'integer' ala Pascal. When you write 'int' everyone knows what you mean, and it's shorter to type. D is derived from C, not Pascal, and it should stick closer to C conventions unless there are good reasons to stray. Sean
Aug 08 2003
"Sean L. Palmer" <palmer.sean verizon.net> wrote in message news:bgvmgb$25ko$1 digitaldaemon.com...D is derived from C, not Pascal, and it should stick closer to Cconventionsunless there are good reasons to stray.Yes, exactly.
Aug 09 2003
"Walter" <walter digitalmars.com> wrote in message news:bh4nql$qhm$3 digitaldaemon.com..."Sean L. Palmer" <palmer.sean verizon.net> wrote in message news:bgvmgb$25ko$1 digitaldaemon.com...well then bit ain't bool and bool aint bit !! to stick close to C bool is stored in int (where int is the most efficient memory operand size no shorter than a short and no longer than a long) which means short on 68k (16 bit bus), int on x86 and I guess short or int on Arm depending on the machine etc and so on) and its not a bit it can only have the values 0 (false) and 1 (true). the result from (a < b) is a bool (in an int) not in a bit.D is derived from C, not Pascal, and it should stick closer to Cconventionsunless there are good reasons to stray.Yes, exactly.
Aug 10 2003
Walter wrote:"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgmfml$2fr1$1 digitaldaemon.com...It gives the impression that it has "bit" semantics! A bit is an integer in the range [0, 1]: bit a; a = 0.1; /* results in 0 */ a = 1.1; /* results in 1 */ a = 2; /* results in 0 */ a = 3; /* results in 1 */ A boolean, on the other hand, has no arithmetic, different casting semantics, no defined integral value in memory, and different purposes. It has an identical value range, but so do ubyte and char."bool" isI've put a bool alias for bit in 0.69. I found "bit" to be appealing, as there is the implication that there is none of this tri-state confusion nonsense we find in C, but others obviously don't see it that way.What wrong impression does bit give? I'm a bit (!) flummoxed as to why people find bit so distasteful.used in C and C++."boolean" describes its semantics without bringing in either unfortunate comparisons (bool, Windows' BOOL) or completely wrong impressions (bit).
Aug 04 2003
"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgn2pr$bk$1 digitaldaemon.com...Walter wrote:as"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgmfml$2fr1$1 digitaldaemon.com...I've put a bool alias for bit in 0.69. I found "bit" to be appealing,Just make: 1. bit implicitly convertible to 0 or 1. 2. casting from x to a bit be defined by: cast(bit)x => (x != 0) fulfilling both roles neatly. (Your third and fourth examples would set a to true.)It gives the impression that it has "bit" semantics! A bit is an integer in the range [0, 1]: bit a; a = 0.1; /* results in 0 */ a = 1.1; /* results in 1 */ a = 2; /* results in 0 */ a = 3; /* results in 1 */ A boolean, on the other hand, has no arithmetic, different casting semantics, no defined integral value in memory, and different purposes. It has an identical value range, but so do ubyte and char."bool" isthere is the implication that there is none of this tri-state confusion nonsense we find in C, but others obviously don't see it that way.What wrong impression does bit give? I'm a bit (!) flummoxed as to why people find bit so distasteful.used in C and C++."boolean" describes its semantics without bringing in either unfortunate comparisons (bool, Windows' BOOL) or completely wrong impressions (bit).
Aug 05 2003
but what about the other way ? int i; cast(boolean)i (implies i!=0) cast(bit)i (implies i&1, given that cast(byte)i is i&0xFF) and here lies the reason for (and difference of) boolean and bit.A boolean, on the other hand, has no arithmetic, different casting semantics, no defined integral value in memory, and different purposes. It has an identical value range, but so do ubyte and char.Just make: 1. bit implicitly convertible to 0 or 1. 2. casting from x to a bit be defined by: cast(bit)x => (x != 0)
Aug 05 2003
"Mike Wynn" <mike.wynn l8night.co.uk> wrote in message news:bgoefc$1b9o$1 digitaldaemon.com...purposes.A boolean, on the other hand, has no arithmetic, different casting semantics, no defined integral value in memory, and differentOk, I see what you are driving at. But the cast(bit)i being (i&1) is not necessary if the former is supported.but what about the other way ? int i; cast(boolean)i (implies i!=0) cast(bit)i (implies i&1, given that cast(byte)i is i&0xFF) and here lies the reason for (and difference of) boolean and bit.It has an identical value range, but so do ubyte and char.Just make: 1. bit implicitly convertible to 0 or 1. 2. casting from x to a bit be defined by: cast(bit)x => (x != 0)
Aug 05 2003
Walter wrote:"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgn2pr$bk$1 digitaldaemon.com...Which is boolean semantics, not bit.Walter wrote:as"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgmfml$2fr1$1 digitaldaemon.com...I've put a bool alias for bit in 0.69. I found "bit" to be appealing,Just make: 1. bit implicitly convertible to 0 or 1. 2. casting from x to a bit be defined by: cast(bit)x => (x != 0)It gives the impression that it has "bit" semantics! A bit is an integer in the range [0, 1]: bit a; a = 0.1; /* results in 0 */ a = 1.1; /* results in 1 */ a = 2; /* results in 0 */ a = 3; /* results in 1 */ A boolean, on the other hand, has no arithmetic, different casting semantics, no defined integral value in memory, and different purposes. It has an identical value range, but so do ubyte and char."bool" isthere is the implication that there is none of this tri-state confusion nonsense we find in C, but others obviously don't see it that way.What wrong impression does bit give? I'm a bit (!) flummoxed as to why people find bit so distasteful.used in C and C++."boolean" describes its semantics without bringing in either unfortunate comparisons (bool, Windows' BOOL) or completely wrong impressions (bit).fulfilling both roles neatly. (Your third and fourth examples would set a to true.)That it can be forced to behave similar to a bit using a lot of casting and support code doesn't change the fact that it's NOT A BIT.
Aug 05 2003
"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgpj3f$2gh8$1 digitaldaemon.com...That it can be forced to behave similar to a bit using a lot of casting and support code doesn't change the fact that it's NOT A BIT.All it would be is: bit b = cast(bit)(d & 1);
Aug 07 2003
Walter wrote:"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgpj3f$2gh8$1 digitaldaemon.com...That it can be forced to behave similar to a bit using a lot of casting and support code doesn't change the fact that it's NOT A BIT.That it can be forced to behave similar to a bit using a lot of casting and support code doesn't change the fact that it's NOT A BIT.All it would be is: bit b = cast(bit)(d & 1);
Aug 08 2003
"Burton Radons" <loth users.sourceforge.net> wrote in message news:bh0c75$2ppg$1 digitaldaemon.com...Walter wrote:I'm with you, my bold bool brother"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgpj3f$2gh8$1 digitaldaemon.com...That it can be forced to behave similar to a bit using a lot of casting and support code doesn't change the fact that it's NOT A BIT.That it can be forced to behave similar to a bit using a lot of casting and support code doesn't change the fact that it's NOT A BIT.All it would be is: bit b = cast(bit)(d & 1);
Aug 08 2003
"Burton Radons" <loth users.sourceforge.net> wrote in message news:bh0c75$2ppg$1 digitaldaemon.com...Walter wrote:I disagree with the assessment that it's a lot of casting and support code. There's only one case, shown above, needing it. I don't think that justifies adding another basic type."Burton Radons" <loth users.sourceforge.net> wrote in message news:bgpj3f$2gh8$1 digitaldaemon.com...That it can be forced to behave similar to a bit using a lot of casting and support code doesn't change the fact that it's NOT A BIT.That it can be forced to behave similar to a bit using a lot of casting and support code doesn't change the fact that it's NOT A BIT.All it would be is: bit b = cast(bit)(d & 1);
Aug 09 2003
after a quick google search found this interesting piece on C and Ada bit fields representation: http://www.ankh-morpork.com/Simon/adabook/c3_7.htm
Aug 05 2003
Walter wrote:"Burton Radons" <loth users.sourceforge.net> wrote in message news:bgmfml$2fr1$1 digitaldaemon.com...Hi, Walter. By adding the alias for bool in a core library (is it in Phobos?), you've made me happy. I just didn't want to deal with resolving conflicting definition of 'bool', as I did in C and C++. Bill"bool" isI've put a bool alias for bit in 0.69. I found "bit" to be appealing, as there is the implication that there is none of this tri-state confusion nonsense we find in C, but others obviously don't see it that way.What wrong impression does bit give? I'm a bit (!) flummoxed as to why people find bit so distasteful.used in C and C++."boolean" describes its semantics without bringing in either unfortunate comparisons (bool, Windows' BOOL) or completely wrong impressions (bit).
Aug 06 2003
"Bill Cox" <bill viasic.com> wrote in message news:3F310C79.7080703 viasic.com...By adding the alias for bool in a core library (is it in Phobos?), you've made me happy. I just didn't want to deal with resolving conflicting definition of 'bool', as I did in C and C++.I think you might be the only one happy with that besides myself <g>.
Aug 07 2003
"Walter" <walter digitalmars.com> wrote in message news:bgmnb5$2n2b$1 digitaldaemon.com..."Burton Radons" <loth users.sourceforge.net> wrote in message news:bgmfml$2fr1$1 digitaldaemon.com...asI've put a bool alias for bit in 0.69. I found "bit" to be appealing,confusionthere is the implication that there is none of this tri-stateMostly they're used to typing 'bool' instead. ;) If it's not in the base language, there *will* end up being many incompatible and conflicting definitions of bool. Once this starts proliferating it will be impossible to add a standard bool type without breaking existing code, as all builtin types are keywords. Personally I don't mind using 0 and 1 instead of true and false; it's shorter to type. Pesky automatic conversions may bite you though. I guess people just want a distinct boolean type that's incompatible with int types, though explicit conversions should still be possible. Helps catch certain kinds of errors. I think the biggest reason may be that you can't use bit as an out parameter. Last I checked you couldn't have pointers to bit either, but I've heard rumors here that it is now possible. Sean"bool" isnonsense we find in C, but others obviously don't see it that way.What wrong impression does bit give? I'm a bit (!) flummoxed as to why people find bit so distasteful.used in C and C++."boolean" describes its semantics without bringing in either unfortunate comparisons (bool, Windows' BOOL) or completely wrong impressions (bit).
Aug 08 2003
"Sean L. Palmer" <palmer.sean verizon.net> wrote in message news:bgvm9a$25g6$1 digitaldaemon.com...I think the biggest reason may be that you can't use bit as an out parameter. Last I checked you couldn't have pointers to bit either, but I've heard rumors here that it is now possible.It's implemented in 0.69.
Aug 09 2003
Burton Radons wrote:Matthew Wilson wrote:I guess I'm lazy, because I like bool better than boolean. I'd have to retrain my fingers to type the extra "ean" letters. My eyes too, because I'm pretty used to seeing "bool", not boolean. However, here's my opinion. Walter is doing all the work of creating the language and developing the compiler. If he likes bit, I can type bit. If there is a real technical reason for a boolean type, I'd be happy to type bool (or boolean if I must.) Mostly I think we are splitting hairs (or bits?) here.Wearing my heretical pragmatist hat, may I pose the question: why do we have a bit type? I am at a loss to think why it is useful (or more useful than bit fields).Its semantics are for boolean. It should be renamed - I want "boolean", as "bool" is just lazy. Walter, is there any reason why it hasn't been renamed?
Aug 06 2003
"Frank Wills" <fdwills sandarh.com> wrote in message news:bgsm61$2cd9$1 digitaldaemon.com...Burton Radons wrote:thanMatthew Wilson wrote:Wearing my heretical pragmatist hat, may I pose the question: why do we have a bit type? I am at a loss to think why it is useful (or more usefulI don't care whether it's bool or boolean. Arguably, since we are using C's terse naming, i.e. int rather than integer, then we should go for bool. It'll also save fatuous editing when porting between C++ and D. But overall, don't care.I guess I'm lazy, because I like bool better than boolean. I'd have to retrain my fingers to type the extra "ean" letters. My eyes too, because I'm pretty used to seeing "bool", not boolean.bit fields).Its semantics are for boolean. It should be renamed - I want "boolean", as "bool" is just lazy. Walter, is there any reason why it hasn't been renamed?However, here's my opinion. Walter is doing all the work of creating the language and developing the compiler. If he likes bit, I can type bit. If there is a real technical reason for a boolean type, I'd be happy to type bool (or boolean if I must.) Mostly I think we are splitting hairs (or bits?) here.Not so. The differences are very important, for the reasons already mentioned several times. We *must* have bool/boolean type, it *must* not be bit-size, and it *should* be the same size as int.
Aug 06 2003
Not so. The differences are very important, for the reasons already mentioned several times. We *must* have bool/boolean type, it *must* notbebit-size, and it *should* be the same size as int.I disagree with the latter part of that. we *must* have a boolean-type with boolean semantics it *can* be implemented in *any* way bit, byte, int, long as long as its passable in,out,inout and you can have a pointer to it. if declared as a extern( C ) boolean b; then it *must* be implemented as an int (same for boolean params in extern(C or Windows) functions. int i; cast(boolean)i equiv to i!=0 if there is a 'bit' type is should be have 'bit' semantics, which means it _can_ be "in" only as bit pointers are extra work. cast(bit)i equiv to i&1 (in line with byte and short cast operators).
Aug 07 2003
In article <bgtu7o$hu1$1 digitaldaemon.com>, Mike Wynn says...I agree with this and many others do also (why does Walter fight this??) It may be Walter's language now but hopefully in the future it will be more than that, I don't think of Stroustrap as "owning" C++Not so. The differences are very important, for the reasons already mentioned several times. We *must* have bool/boolean type, it *must* notbebit-size, and it *should* be the same size as int.I disagree with the latter part of that. we *must* have a boolean-type with boolean semantics it *can* be implemented in *any* way bit, byte, int, long as long as its passable in,out,inout and you can have a pointer to it. if declared as a extern( C ) boolean b; then it *must* be implemented as an int (same for boolean params in extern(C or Windows) functions. int i; cast(boolean)i equiv to i!=0 if there is a 'bit' type is should be have 'bit' semantics, which means it _can_ be "in" only as bit pointers are extra work. cast(bit)i equiv to i&1 (in line with byte and short cast operators).
Aug 08 2003
"Matthew Wilson" <dmd synesis.com.au> wrote in message news:bgsml6$2cu1$1 digitaldaemon.com...Not so. The differences are very important, for the reasons already mentioned several times. We *must* have bool/boolean type, it *must* not be bit-size, and it *should* be the same size as int.If bits are not going to be usable as out parameters, then we definitely need separate bool (which can be used as out parameter), otherwise I can live with bool as language defined typedef for bit. Bit size should be really one bit and bit arrays should be "packed" (ie an array with 8 items should be only 1 byte long); I think this is true now. Bool size does *not* need to be the same as int at all, when it is not defined as extern(C). C++ uses one byte for bools and it is definitely different from int.
Aug 10 2003
"Peter Hercek" <vvp no.post.spam.sk> wrote in message news:bh6o62$2kru$1 digitaldaemon.com..."Matthew Wilson" <dmd synesis.com.au> wrote in messagenews:bgsml6$2cu1$1 digitaldaemon.com...beNot so. The differences are very important, for the reasons already mentioned several times. We *must* have bool/boolean type, it *must* notneedbit-size, and it *should* be the same size as int.If bits are not going to be usable as out parameters, then we definitelyseparate bool (which can be used as out parameter), otherwise I can livewithbool as language defined typedef for bit. Bit size should be really onebitand bit arrays should be "packed" (ie an array with 8 items should beonly1 byte long); I think this is true now. Bool size does *not* need to be the same as int at all, when it is notdefinedas extern(C). C++ uses one byte for bools and it is definitely differentfrom int. exactly C++ uses ...... C however uses "int" (and that's a C "int" NOT a D int) and D only has C linkage not C++
Aug 10 2003
"Mike Wynn" <mike.wynn l8night.co.uk> wrote in message news:bh6oqf$2lbm$1 digitaldaemon.com..."Peter Hercek" <vvp no.post.spam.sk> wrote in message news:bh6o62$2kru$1 digitaldaemon.com...not"Matthew Wilson" <dmd synesis.com.au> wrote in messagenews:bgsml6$2cu1$1 digitaldaemon.com...Not so. The differences are very important, for the reasons already mentioned several times. We *must* have bool/boolean type, it *must*beliveneedbit-size, and it *should* be the same size as int.If bits are not going to be usable as out parameters, then we definitelyseparate bool (which can be used as out parameter), otherwise I canwithdifferentbool as language defined typedef for bit. Bit size should be really onebitand bit arrays should be "packed" (ie an array with 8 items should beonly1 byte long); I think this is true now. Bool size does *not* need to be the same as int at all, when it is notdefinedas extern(C). C++ uses one byte for bools and it is definitelyfrom int. exactly C++ uses ...... C however uses "int" (and that's a C "int" NOT a D int) and D only has C linkage not C++Well, both C++ (bool) and C (_Bool) have native bool types, and they are implemented as 8-bit quantities on every compiler I have access to. But most pre-C99 boolean types in C are implemented (correctly) as int, and so should D's.
Aug 10 2003
"Matthew Wilson" <matthew stlsoft.org> wrote in message news:bh6va4$2rfm$1 digitaldaemon.com...[snip]Well, both C++ (bool) and C (_Bool) have native bool types, and they are implemented as 8-bit quantities on every compiler I have access to. But most pre-C99 boolean types in C are implemented (correctly) as int, and so should D's.Why it should be int and not 8bit quantity? Sorry, I do not want to poke my nose into this too much, I'm only interested why int is better. In memory individual variables would be aligned anyway and in arrays and sometimes structs it is good to consume less memory IMHO. From programmer's point of view the sematics is different from int.
Aug 10 2003
"Peter Hercek" <vvp no.post.spam.sk> wrote in message news:bh74g5$313v$1 digitaldaemon.com..."Matthew Wilson" <matthew stlsoft.org> wrote in messagenews:bh6va4$2rfm$1 digitaldaemon.com...and[snip]Well, both C++ (bool) and C (_Bool) have native bool types, and they are implemented as 8-bit quantities on every compiler I have access to. But most pre-C99 boolean types in C are implemented (correctly) as int,myso should D's.Why it should be int and not 8bit quantity? Sorry, I do not want to pokenose into this too much, I'm only interested why int is better. In memoryindividualvariables would be aligned anyway and in arrays and sometimes structs itis goodto consume less memory IMHO. From programmer's point of view the sematicsisdifferent from int.not on all archs, (read byte as 8bit, short->16bit, int->32bit [D defs]) 68K can read byte at byte alignment, short and int at 16 bit alignment ARM can read byte byte, short 16bit aligned, int only at 32bit aligned. x86 any at any but there are performance issues with unalign loading and many compiler align the stack on cache line boundaries for speed. int is not better, it is just what the pre-C99 spec uses (same as originally C would not allow structs to be passed by value) as far as I'm aware void func( bool a, bool b, bool c ){ .... } will use 3 stack slots (or registers) [not checked] so will push 3 16 bit quantites under dos, push 3 dwords under win32/unix and will use r0..r2 on Arm. thus "int" [C def] rather than packing them into bytes or bits.
Aug 11 2003
1. Efficiency ... mostly. However, I recognise that int is not the most efficient in all circumstances, just a significant proportion of them. 2. Safety. Since we are interoperating with Win32, where it is possible for BOOL to return a "true" value outside of 1-255, which would be missed. If D does what C++ does, which is to do an implict test, as in int i; bool b = i; is translated to int i bool b = (i != 0) ? true : false; then it is safe, but we're back to inefficiency. Incidentally, only CodeWarrior and Visual C++ warn about the efficiency concerns of this conversion. All other Win32 compilers (that I have access to, which is Borland, Digital Mars, GCC, Intel, Watcom) do not warn. I'm very interested in efficiency, but am more interested in safety. My perhaps simplistic notion, therefore, is to make bool(ean) be the same size as int. If someone can come up with an efficient & safe scheme that is better, I'll jump on board "Peter Hercek" <vvp no.post.spam.sk> wrote in message news:bh74g5$313v$1 digitaldaemon.com..."Matthew Wilson" <matthew stlsoft.org> wrote in messagenews:bh6va4$2rfm$1 digitaldaemon.com...and[snip]Well, both C++ (bool) and C (_Bool) have native bool types, and they are implemented as 8-bit quantities on every compiler I have access to. But most pre-C99 boolean types in C are implemented (correctly) as int,myso should D's.Why it should be int and not 8bit quantity? Sorry, I do not want to pokenose into this too much, I'm only interested why int is better. In memoryindividualvariables would be aligned anyway and in arrays and sometimes structs itis goodto consume less memory IMHO. From programmer's point of view the sematicsisdifferent from int.
Aug 11 2003
What we'd all like to have is a choice between a fast bool and a small bool. We need a "pragma packed" decorator. ;) Or the compiler could be smart about it and use 1-byte bools for small fixed-size arrays, 4-byte bools for single bools that aren't next to any other bools in memory, and 1-bit bools for large arrays. I wonder if the sizeof(bit) could be changed depending on the situation without making the language really difficult. Sean "Matthew Wilson" <matthew stlsoft.org> wrote in message news:bh6va4$2rfm$1 digitaldaemon.com...Well, both C++ (bool) and C (_Bool) have native bool types, and they are implemented as 8-bit quantities on every compiler I have access to. But most pre-C99 boolean types in C are implemented (correctly) as int,andso should D's.
Aug 11 2003
Now you're talking! ;) "Sean L. Palmer" <palmer.sean verizon.net> wrote in message news:bh8ia5$1gpn$1 digitaldaemon.com...What we'd all like to have is a choice between a fast bool and a smallbool.We need a "pragma packed" decorator. ;) Or the compiler could be smart about it and use 1-byte bools for small fixed-size arrays, 4-byte bools for single bools that aren't next to any other bools in memory, and 1-bit bools for large arrays. I wonder if the sizeof(bit) could be changed depending on the situation without making the language really difficult. Sean "Matthew Wilson" <matthew stlsoft.org> wrote in message news:bh6va4$2rfm$1 digitaldaemon.com...Well, both C++ (bool) and C (_Bool) have native bool types, and they are implemented as 8-bit quantities on every compiler I have access to. But most pre-C99 boolean types in C are implemented (correctly) as int,andso should D's.
Aug 11 2003
Well if the compiler can do bit*, it should be able to do out bit. There is no technical reason why this wouldn't work, it's just a matter of Walter's time and inclination. Sean "Peter Hercek" <vvp no.post.spam.sk> wrote in message news:bh6o62$2kru$1 digitaldaemon.com..."Matthew Wilson" <dmd synesis.com.au> wrote in messagenews:bgsml6$2cu1$1 digitaldaemon.com...beNot so. The differences are very important, for the reasons already mentioned several times. We *must* have bool/boolean type, it *must* notneedbit-size, and it *should* be the same size as int.If bits are not going to be usable as out parameters, then we definitelyseparate bool (which can be used as out parameter), otherwise I can livewithbool as language defined typedef for bit. Bit size should be really onebitand bit arrays should be "packed" (ie an array with 8 items should beonly1 byte long); I think this is true now. Bool size does *not* need to be the same as int at all, when it is notdefinedas extern(C). C++ uses one byte for bools and it is definitely differentfrom int.
Aug 11 2003
"Frank Wills" <fdwills sandarh.com> wrote in message news:bgk5n1$bs2$1 digitaldaemon.com...Mike, Sure, sure, yes, yes, I imagine that most people on this list understand everything you are explaining, and the issues involved (who on this list doesn't know what a bit is, and that it is a part of a larger addressable unit in memory?)I appologise, just giving what I could remember from the answer I got from Walter when I tried `out bit b` ages ago. I assumed no out bit meant no bit * too, so never bothered with bit * as a solution (or inout bit) I think I know what you mean, but "part of a larger addressable unit in memory" bits is smallest sub part of the addressable units of the CPU, isnt it more that all CPU's (that I've used) only allow direct addressing to multi bit quantities units I assumed everyone know that, as they all knew most RISC cpus can only address units at unit alignment. I'm in the drop bit and give us a boolean conceptual type camp. or if you can have bit *, bit[] give us full useage of it, allow an int to be cast to a bit[] and vice-versa or even a int[] to a bit[] and allow set scanning etc in the bit[]. as I've said before I believe a language should be driven by its semantics and not its implementation the better you can tell a compiler what you want done (rather than how) the better the chances the compiler can optimise your code. my desire for boolean is that the storage of a boolean in undefined, so extern C api's which use int for boolean and D code with booleans can interoperate without the need to cast.
Aug 04 2003