May 27, 2002 Re: To Bool or not to Bool, that is the question... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert W. Cunningham | In article <3CE1EEA3.283F59E7@acm.org>, Robert W. Cunningham says... > >Remember, Boolean Algebra is part of Set Theory, and is not in any way based on integer algebra. By definition, booleans are not integers! They aren't even single-bit integers. The confusion between boolean values and bits in the realm of computer programming occurred only when computers were developed that used bits (most early electronic computers were pure decimal, with binary computers following later). And C, being the language most closely mapped to a specific computer architecture (the PDP-11), completely failed to make the distinction. And we've been living with the consequences ever since. Um ... my recollection is that almost immediately all computers went to binary, for very good reasons. I have never spoken to Kernighan or Ritchie, but my strong suspicion is that the confusion was intentional. The goal was a compact and powerful language. I think they succeeded. From my point of view, the approach was an idea whose time had come, and has now passed. In every COBOL shop where I have ever worked, you could get a boolean packing and unpacking subroutine. In every on of those shops, this was strictly against company policy. No one would openly admit knowing about it or using it. Documentation did not exist. Everyone would tell you how to do it, behind closed doors. > >Does anyone remember how to implement a multi-bit full adder with carry using only simple gates? Do I lose all credibility if I admit this? > >If the notions of single-bit integers and boolean entities are universally and inseparably intertwined in the minds of all-programmers-who-aren't-me, then I'll take back my rant, and return quietly to my corner. > Single-bit integers and boolean entities are NOT inseparably intertwined in my mind. > >-BobC |
May 28, 2002 Re: To Bool or not to Bool, that is the question... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> ha scritto nel messaggio news:actm89$9vi$1@digitaldaemon.com... > > "OddesE" <OddesE_XYZ@hotmail.com> wrote in message news:abubnh$d8t$1@digitaldaemon.com... > > You are right, but then we still keep the problem > > of not being able to use them as out parameters. > > Walter, what do true and false do at the moment? > > I thought they where already defined as being 0 > > and 1... > > They're 0 and 1 of type bit. > > As this thread shows, unfortunately, there simply is no right way to implement a boolean type. I remember the same discussion raging with C, with > no consenus resolution. The problem is not "there isn't a right way to implement booleans", it's "there isn't an easy way to implement booleans". Any language I know of has its tricky implementation of booleans. None of them do it the right way. CPUs don't use booleans, so it's a difficult task to give support for it the right way. Ciao. |
May 28, 2002 Re: To Bool or not to Bool, that is the question... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roberto Mariottini | "Roberto Mariottini" <rmariottini@lycosmail.com> wrote in message news:acvd57$177j$1@digitaldaemon.com... > The problem is not "there isn't a right way to implement booleans", it's > "there isn't an easy way to implement booleans". > Any language I know of has its tricky implementation of booleans. None of > them > do it the right way. > CPUs don't use booleans, so it's a difficult task to give support for it the > right > way. Personally, I'm pretty happy with what we have in D right now. The only good thing would be to have out/inout bit parameters (this does NOT imply bit* pointers). |
May 28, 2002 Re: To Bool or not to Bool, that is the question... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | A agree with Pavel, although I wouldn't mind some kind of bit* that let one address and iterate through individual bits. ;) Behind the scenes it's just a int* and 5 extra address bits which get converted to a bitmask using 1<<bitidx shifts. The + operator for it would add modulo 32 to the bitidx and div 32 to the int*. Then we could point into bit arrays and walk them just like any other array type. Sean "Pavel Minayev" <evilone@omen.ru> wrote in message news:ad01al$26t1$1@digitaldaemon.com... > "Roberto Mariottini" <rmariottini@lycosmail.com> wrote in message news:acvd57$177j$1@digitaldaemon.com... > > > The problem is not "there isn't a right way to implement booleans", it's > > "there isn't an easy way to implement booleans". > > Any language I know of has its tricky implementation of booleans. None of > > them > > do it the right way. > > CPUs don't use booleans, so it's a difficult task to give support for it > the > > right > > way. > > Personally, I'm pretty happy with what we have in D right now. The only good thing would be to have out/inout bit parameters (this does NOT imply bit* pointers). |
Copyright © 1999-2021 by the D Language Foundation