digitalmars.D - Wouldn't it be better if ...
- Peter (4/4) May 02 2004 I was looking at some of the modules such as ctype and math, and see tha...
- Matthew (14/18) May 02 2004 Sure would, but we can't agree on what boolean would be!
- J Anderson (7/14) May 02 2004 Won't bit be an integral type be a size that is optimal for the
- School (3/29) May 03 2004 It would be even better if you write a book called "Learning D" or "The
- Matthew (7/36) May 03 2004 my
- Brad Anderson (3/56) May 04 2004 http://www.thedprogramminglanguage.com/
- Stephan Wienczny (4/8) May 04 2004 If you look at the whois entry, you will see that the owner is Synesis
- Brad Anderson (2/12) May 04 2004
- Walter (8/12) May 02 2004 the
- Hauke Duden (8/31) May 03 2004 Well, then maybe a boolean shouldn't be a bit (hint,hint), but its own
- Walter (20/29) May 03 2004 instructions
I was looking at some of the modules such as ctype and math, and see that the "is" functions (i.e. isalpha, isnan) return a value of type int. Given that this is a modern language having boolean types available, would it not be better to return a value of type boolean? I'm thinking that code would be clearner.
May 02 2004
Sure would, but we can't agree on what boolean would be! I think it should be an integral type, whose size is the same as that of the architecture (for performance; the various supporting reasons for this are in my <self-serving promotion>forthcoming book "Imperfect C++"</self-serving promotion>), and which should *not* be implicitly convertible to/from any other integral type. But Walter, and a handful of other people, seem content to have it be aliased to bit. In the libraries I write, I typedef (remember D's typedefs are strong ones) boolean from int, and use the casts as appropriate to return them. Walter doesn't like this, but I'm immutable on this point. "Peter" <Peter_member pathlink.com> wrote in message news:c74i4i$l54$1 digitaldaemon.com...I was looking at some of the modules such as ctype and math, and see that the "is" functions (i.e. isalpha, isnan) return a value of type int. Given that this is a modern language having boolean types available, would it not bebetterto return a value of type boolean? I'm thinking that code would be clearner.
May 02 2004
Matthew wrote:Sure would, but we can't agree on what boolean would be! I think it should be an integral type, whose size is the same as that of the architecture (for performance) But Walter, and a handful of other people, seem content to have it be aliased to bit.Won't bit be an integral type be a size that is optimal for the architecture. I mean for the systems we use now byte is the most optimal choice for Boolean (due to caching and other factors). If your using a single bit then it will be the size of a byte. -- -Anderson: http://badmama.com.au/~anderson/
May 02 2004
Matthew 提到:Sure would, but we can't agree on what boolean would be! I think it should be an integral type, whose size is the same as that of the architecture (for performance; the various supporting reasons for this are in my <self-serving promotion>forthcoming book "Imperfect C++"</self-serving promotion>), and which should *not* be implicitly convertible to/from any other integral type. But Walter, and a handful of other people, seem content to have it be aliased to bit. In the libraries I write, I typedef (remember D's typedefs are strong ones) boolean from int, and use the casts as appropriate to return them. Walter doesn't like this, but I'm immutable on this point. "Peter" <Peter_member pathlink.com> wrote in message news:c74i4i$l54$1 digitaldaemon.com...It would be even better if you write a book called "Learning D" or "The D Programming Language" or "Thinking in D" or "Prefect D".I was looking at some of the modules such as ctype and math, and see that the "is" functions (i.e. isalpha, isnan) return a value of type int. Given that this is a modern language having boolean types available, would it not bebetterto return a value of type boolean? I'm thinking that code would be clearner.
May 03 2004
"School" <itsnotvalid-news yahoo.com.hk> wrote in message news:c75hcv$23rj$1 digitaldaemon.com...Matthew 提到:mySure would, but we can't agree on what boolean would be! I think it should be an integral type, whose size is the same as that of the architecture (for performance; the various supporting reasons for this are inother<self-serving promotion>forthcoming book "Imperfect C++"</self-serving promotion>), and which should *not* be implicitly convertible to/from anytointegral type. But Walter, and a handful of other people, seem content to have it be aliaseddoesn'tbit. In the libraries I write, I typedef (remember D's typedefs are strong ones) boolean from int, and use the casts as appropriate to return them. WalterWell, you may be onto something there. ;)like this, but I'm immutable on this point. "Peter" <Peter_member pathlink.com> wrote in message news:c74i4i$l54$1 digitaldaemon.com...It would be even better if you write a book called "Learning D" or "The D Programming Language" or "Thinking in D" or "Prefect D".I was looking at some of the modules such as ctype and math, and see that the "is" functions (i.e. isalpha, isnan) return a value of type int. Given that this is a modern language having boolean types available, would it not bebetterto return a value of type boolean? I'm thinking that code would be clearner.
May 03 2004
http://www.thedprogramminglanguage.com/ Wonder who owns that domain name... Matthew wrote:"School" <itsnotvalid-news yahoo.com.hk> wrote in message news:c75hcv$23rj$1 digitaldaemon.com...Matthew 提到:mySure would, but we can't agree on what boolean would be! I think it should be an integral type, whose size is the same as that of the architecture (for performance; the various supporting reasons for this are inother<self-serving promotion>forthcoming book "Imperfect C++"</self-serving promotion>), and which should *not* be implicitly convertible to/from anytointegral type. But Walter, and a handful of other people, seem content to have it be aliaseddoesn'tbit. In the libraries I write, I typedef (remember D's typedefs are strong ones) boolean from int, and use the casts as appropriate to return them. WalterWell, you may be onto something there. ;)like this, but I'm immutable on this point. "Peter" <Peter_member pathlink.com> wrote in message news:c74i4i$l54$1 digitaldaemon.com...It would be even better if you write a book called "Learning D" or "The D Programming Language" or "Thinking in D" or "Prefect D".I was looking at some of the modules such as ctype and math, and see that the "is" functions (i.e. isalpha, isnan) return a value of type int. Given that this is a modern language having boolean types available, would it not bebetterto return a value of type boolean? I'm thinking that code would be clearner.
May 04 2004
If you look at the whois entry, you will see that the owner is Synesis Software and the administrative contact is Dr Matthew D. Wilson Brad Anderson wrote:http://www.thedprogramminglanguage.com/ Wonder who owns that domain name...
May 04 2004
I'm shocked beyond all reason. ;) Stephan Wienczny wrote:If you look at the whois entry, you will see that the owner is Synesis Software and the administrative contact is Dr Matthew D. Wilson Brad Anderson wrote:http://www.thedprogramminglanguage.com/ Wonder who owns that domain name...
May 04 2004
"Peter" <Peter_member pathlink.com> wrote in message news:c74i4i$l54$1 digitaldaemon.com...I was looking at some of the modules such as ctype and math, and see thatthe"is" functions (i.e. isalpha, isnan) return a value of type int. Giventhatthis is a modern language having boolean types available, would it not bebetterto return a value of type boolean? I'm thinking that code would beclearner. Generally, a computation of 0 or !0 involves one or two less instructions than converting it to 0 or 1.
May 02 2004
Walter wrote:"Peter" <Peter_member pathlink.com> wrote in message news:c74i4i$l54$1 digitaldaemon.com...Well, then maybe a boolean shouldn't be a bit (hint,hint), but its own type where true simply means !=0. IMHO, your using int instead of bool for a situation where you really MEAN a boolean is a tell-tale sign that something is wrong with the current bool implementation. Not that it hasn't been mentioned before ;). HaukeI was looking at some of the modules such as ctype and math, and see thatthe"is" functions (i.e. isalpha, isnan) return a value of type int. Giventhatthis is a modern language having boolean types available, would it not bebetterto return a value of type boolean? I'm thinking that code would beclearner. Generally, a computation of 0 or !0 involves one or two less instructions than converting it to 0 or 1.
May 03 2004
"Hauke Duden" <H.NS.Duden gmx.net> wrote in message news:c752e6$1e7a$1 digitaldaemon.com...Walter wrote:instructionsGenerally, a computation of 0 or !0 involves one or two lessI'm just one of those people, probably very few in number, who think that C got it right by using 'int' for it and testing for 0 or !0. It's very efficient, and I am loathe to give that up for anything less than a thoroughly compelling reason. It's served me well for 20+ years of C coding. There are 3 scenarios for a boolean: 1) need it to be fast 2) need a single value to be small 3) need a packed array of boolean values 'int' serves (1) well. D's 'bit[]' serves (3), and 'bit' does double duty by also being a byte wide value when used outside of an array, serving (2).than converting it to 0 or 1.Well, then maybe a boolean shouldn't be a bit (hint,hint), but its own type where true simply means !=0.IMHO, your using int instead of bool for a situation where you really MEAN a boolean is a tell-tale sign that something is wrong with the current bool implementation.While I see your point, I don't view it that way. I view it as getting comfortable using an idiom that maps well onto efficient execution on the hardware. Perhaps one reason I am so comfortable with it is all the assembler programming I've done.Not that it hasn't been mentioned before ;).Indeed. I recall the usenet flame wars on this back in the 1980's. The various camps have all long since dug in and well fortified their positions, so I don't think anyone is going to change their mind <g>.
May 03 2004