digitalmars.D.bugs - std.math "is" functions
- Miguel F. Simões (6/6) Apr 16 2005 This is not really a bug...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (6/11) Apr 16 2005 D does not have booleans. Thus, it can return either bit or byte or int.
- Ben Hinkle (10/22) Apr 16 2005 oh Anders, 'bit' really doesn't sit well with you, eh? The poor guy prob...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (14/26) Apr 16 2005 Nope. But I usually try to constrain myself better... :-)
- Miguel Ferreira Simões (6/11) Apr 16 2005 I am getting a little confused...
- Ben Hinkle (6/15) Apr 16 2005 That sounds like a problem. Can you reproduce the warning? Maybe it was
- Derek Parnell (10/14) Apr 16 2005 I find that the -w switch is very useful. Its implementation also very
This is not really a bug... I am not sure if the functions that belong to std.math and start with "is" (isnan, isfinite, isnormal, issubnormal) are supposed to return an int. In my humble opinion, we are testing a boolean condition. -- Miguel Ferreira Simões
Apr 16 2005
Miguel F. Simões wrote:This is not really a bug... I am not sure if the functions that belong to std.math and start with "is" (isnan, isfinite, isnormal, issubnormal) are supposed to return an int. In my humble opinion, we are testing a boolean condition.D does not have booleans. Thus, it can return either bit or byte or int. (but I agree with you, it probably *should* be "bool"... It just isn't?) --anders PS. See also "int opEquals(Object o);" in Object. It returns true/false too.
Apr 16 2005
"Anders F Björklund" <afb algonet.se> wrote in message news:d3qpei$2gvq$1 digitaldaemon.com...Miguel F. Simões wrote:oh Anders, 'bit' really doesn't sit well with you, eh? The poor guy probably didn't realize what a natural question involving boolean can touch off around here :-) Some functions return int because 'if' conditionals can accept ints and there is a performance penalty (probably small but I don't know) involved with converting an int to a bit (aka bool). I don't know what the impact of returning bool would be on the performance of isnan and friends. I think it would be worth investigating.This is not really a bug... I am not sure if the functions that belong to std.math and start with "is" (isnan, isfinite, isnormal, issubnormal) are supposed to return an int. In my humble opinion, we are testing a boolean condition.D does not have booleans. Thus, it can return either bit or byte or int.(but I agree with you, it probably *should* be "bool"... It just isn't?) --anders PS. See also "int opEquals(Object o);" in Object. It returns true/false too.
Apr 16 2005
Ben Hinkle wrote:Nope. But I usually try to constrain myself better... :-) It's better than _Bool, though ? (that C99 calls it)oh Anders, 'bit' really doesn't sit well with you, eh?In my humble opinion, we are testing a boolean condition.D does not have booleans. Thus, it can return either bit or byte or int.The poor guy probably didn't realize what a natural question involving boolean can touch off around here :-)It's a natural question. And the"natural" answer is that neither C nor D *have* a boolean type, just integers... This will continue to come up. That's why I wrote: http://www.prowiki.org/wiki4d/wiki.cgi?BitsAndBoolsSome functions return int because 'if' conditionals can accept ints and there is a performance penalty (probably small but I don't know) involved with converting an int to a bit (aka bool). I don't know what the impact of returning bool would be on the performance of isnan and friends. I think it would be worth investigating.byte is smaller/slower, int is larger/faster - that's pretty well-known. C++ chose the route of not fixing the boolean type size, D set it at 1. I'm not sure the gained performance is worth the confusion, but anyway. In Altivec, they are called "bool char", "bool short" and "bool int" ? (i.e. "bool" is a prefix there, just there is an "unsigned" as usual). bit is a strange pseudo-boolean hybrid, neither integer nor boolean... I'm sure it will continue to surprise D users, for many years to come. --anders
Apr 16 2005
Some functions return int because 'if' conditionals can accept ints and there is a performance penalty (probably small but I don't know) involved with converting an int to a bit (aka bool). I don't know what the impact of returning bool would be on the performance of isnan and friends. I think it would be worth investigating.I am getting a little confused... The reason that led me to raise this issue... was a warning caused by a conditional statement that did not accept bools! But I guess it should be allowed. Thanks. Miguel
Apr 16 2005
"Miguel Ferreira Simões" <Kobold netcabo.pt> wrote in message news:d3sj8t$pt1$1 digitaldaemon.com...That sounds like a problem. Can you reproduce the warning? Maybe it was warning about casting to int to bool? That happens all the time and it IMO makes the -w option the dmd pretty useless. Whenever I try -w it stops on the first warning and refuses to keep going.Some functions return int because 'if' conditionals can accept ints and there is a performance penalty (probably small but I don't know) involved with converting an int to a bit (aka bool). I don't know what the impact of returning bool would be on the performance of isnan and friends. I think it would be worth investigating.I am getting a little confused... The reason that led me to raise this issue... was a warning caused by a conditional statement that did not accept bools! But I guess it should be allowed.
Apr 16 2005
On Sun, 17 Apr 2005 00:59:15 -0400, Ben Hinkle wrote: [snip]Maybe it was warning about casting to int to bool? That happens all the time and it IMO makes the -w option the dmd pretty useless. Whenever I try -w it stops on the first warning and refuses to keep going.I find that the -w switch is very useful. Its implementation also very annoying in that it stops after only a few warnings have been displayed. Annoying because it slows down the process of fixing up the code. But it is still useful in that I can at least find suspect code using -w. -- Derek Parnell Melbourne, Australia 17/04/2005 3:25:05 PM
Apr 16 2005