digitalmars.D.bugs - Is it a bug?
-
Andrew Fedoniouk
(12/12)
Mar 06 2005
- Derek Parnell (9/19) Mar 06 2005 Just a comment, but you can fix this the long way ...
- Thomas Kuehne (10/25) Mar 17 2005 -----BEGIN PGP SIGNED MESSAGE-----
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (4/16) Mar 17 2005 The "short" usage above is more like... gross, though ? :-)
- Derek Parnell (8/27) Mar 17 2005 Oh absolutely. I'd shoot anyone in my teams who'd try to get away with
- zwang (3/19) Mar 06 2005 This is a very annoying "feature" of dmd -- a blatant discrimination of
- Nick (4/23) Mar 07 2005 Personally I like the feature, just not the error message, which, as And...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (5/10) Mar 07 2005 As long as 'true' is an integer 1, it's actually somewhat correct ;-)
<d> bool b() { return true; } bool quit; if( quit = b() ) // <--------- return 0; </d> DMD 0.114 reports: .\test.d(17): '=' does not give a boolean result I understand the intention but statement does have boolean result. Am I on the right side? Andrew Fedoniouk.
Mar 06 2005
On Sun, 6 Mar 2005 17:24:12 -0800, Andrew Fedoniouk wrote:<d> bool b() { return true; } bool quit; if( quit = b() ) // <--------- return 0; </d> DMD 0.114 reports: .\test.d(17): '=' does not give a boolean resultJust a comment, but you can fix this the long way ... or the short way ... -- Derek Melbourne, Australia 7/03/2005 12:45:27 PM
Mar 06 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Derek Parnell schrieb am Mon, 7 Mar 2005 12:45:51 +1100:On Sun, 6 Mar 2005 17:24:12 -0800, Andrew Fedoniouk wrote:Where is this use of "," documented? Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCOaIh3w+/yD4P9tIRAsMGAJsG5CLaiVIfC9Ud3OppNXec5h/MnQCeOmYC 7jpaCW5NEMg++MBnJbIOab0= =l6yg -----END PGP SIGNATURE-----<d> bool b() { return true; } bool quit; if( quit = b() ) // <--------- return 0; </d> DMD 0.114 reports: .\test.d(17): '=' does not give a boolean resultJust a comment, but you can fix this the long way ... or the short way ...
Mar 17 2005
Thomas Kuehne wrote:http://www.digitalmars.com/d/expression.html#ExpressionJust a comment, but you can fix this the long way ... or the short way ...Where is this use of "," documented?The left operand of the , is evaluated, then the right operand is evaluated. The type of the expression is the type of the right operand, and the result is the result of the right operand.The "short" usage above is more like... gross, though ? :-) --anders
Mar 17 2005
On Thu, 17 Mar 2005 16:32:16 +0100, Anders F Björklund wrote:Thomas Kuehne wrote:Oh absolutely. I'd shoot anyone in my teams who'd try to get away with that. I just wanted to highlight that DMD is not catching all the possible ways you can (ab)use the 'if (A = B)' idiom. -- Derek Parnell Melbourne, Australia 18/03/2005 7:50:41 AMhttp://www.digitalmars.com/d/expression.html#ExpressionJust a comment, but you can fix this the long way ... or the short way ...Where is this use of "," documented?The left operand of the , is evaluated, then the right operand is evaluated. The type of the expression is the type of the right operand, and the result is the result of the right operand.The "short" usage above is more like... gross, though ? :-)
Mar 17 2005
This is a very annoying "feature" of dmd -- a blatant discrimination of <AssignExpression>! Andrew Fedoniouk wrote:<d> bool b() { return true; } bool quit; if( quit = b() ) // <--------- return 0; </d> DMD 0.114 reports: .\test.d(17): '=' does not give a boolean result I understand the intention but statement does have boolean result. Am I on the right side? Andrew Fedoniouk.
Mar 06 2005
Personally I like the feature, just not the error message, which, as Andrew demonstrates, claims something that is clearly not true. Nick In article <d0ggi4$1b9v$1 digitaldaemon.com>, zwang says...This is a very annoying "feature" of dmd -- a blatant discrimination of <AssignExpression>! Andrew Fedoniouk wrote:<d> bool b() { return true; } bool quit; if( quit = b() ) // <--------- return 0; </d> DMD 0.114 reports: .\test.d(17): '=' does not give a boolean result I understand the intention but statement does have boolean result. Am I on the right side? Andrew Fedoniouk.
Mar 07 2005
Nick wrote:.\test.d(17): '=' does not give a boolean resultThis is a very annoying "feature" of dmd -- a blatant discrimination of <AssignExpression>!Personally I like the feature, just not the error message, which, as Andrew demonstrates, claims something that is clearly not true.As long as 'true' is an integer 1, it's actually somewhat correct ;-) And you should almost always write those "if" expressions out anyway... If not by using two statements, then at least with an extra parenthesis. --anders
Mar 07 2005