digitalmars.D - for in D versus C and C++
- Steve Teale (3/3) Mar 19 2009 for (; a
- Sergey Gromov (4/9) Mar 19 2009 for (; a
- =?UTF-8?B?QWxleGFuZGVyIFDDoW5law==?= (2/6) Mar 19 2009 Only in Enterprise Software!
- BCS (2/15) Mar 19 2009 it's a trivial fix and easy to find. Heck, you hardly need to think!
- bearophile (4/5) Mar 19 2009 And it helps to avoid other kinds of bugs quite less easy to find. I hav...
- Walter Bright (15/30) Mar 19 2009 No, it isn't easy to find. This is in D because a colleague of mine, who...
- Denis Koroskin (23/52) Mar 19 2009 Funny enough, or programming department chief posted the following quest...
- Denis Koroskin (2/62) Mar 19 2009 That was less than a week ago. I'd say that this type of bugs will live ...
- Walter Bright (5/7) Mar 19 2009 The thing is, even if the programmer *intended* to put the ; there, it
- Rioshin an'Harthen (8/15) Mar 20 2009 I have a habit of indenting the semicolon on the following line, if I wa...
- Walter Bright (4/15) Mar 20 2009 Yes, that's ok, too. The only issue with it as far as working it into
- Sean Kelly (4/19) Mar 20 2009 Sounds like HTTP/HTML. The best I've come up with so far for parsing
- Walter Bright (4/7) Mar 20 2009 When you see ad-hoc designs like that, it's obvious the designer has no
- Sean Kelly (7/14) Mar 20 2009 I very much agree. In fact, I'd go so far as to say that my compiler de...
- Walter Bright (14/20) Mar 20 2009 Reminds me of a metal shop class I heard about where for the first
- Georg Wrede (7/22) Mar 21 2009 Sometimes I need to have a command line UI in a program. Such programs
- Walter Bright (4/12) Mar 21 2009 If it's 5 or 10, you can get by with ad-hoc. But if you find yourself
- Sean Kelly (5/19) Mar 21 2009 I've found that once I created one lexer it could be re-used pretty
- Walter Bright (4/8) Mar 21 2009 When I was looking into parsing date strings, I thought it would be much...
- Georg Wrede (17/26) Mar 23 2009 Ah, seems you can't parse dates in Nepal.
- Georg Wrede (4/13) Mar 23 2009 It's a shame that this kind of lexing/parsing seems to need gotos. I
- Georg Wrede (3/5) Mar 23 2009 But then in those times, when somebody said "Michael Jackson", everybody...
- Robert Fraser (5/8) Mar 20 2009 The Descent port of the DMDFE lexer does this for formatting source
- BCS (7/28) Mar 19 2009 Um, that's not what I was referring to. The problem the OP referenced se...
- Steve Teale (3/39) Mar 19 2009 I just find this scary, because although it says at the top of the page ...
- Walter Bright (6/13) Mar 19 2009 It shouldn't be scary, because the idea is if some common C struct is
- Denis Koroskin (2/15) Mar 19 2009 I believe he is asking for a way to force that code to compile (a compil...
- Gide Nwawudu (6/46) Mar 19 2009 What D is saying, is that the existing code is likely to be wrong, and
- Ary Borenszweig (4/21) Mar 19 2009 It's not easy to find. I didn't understand why that "for" was illegal
- BCS (2/4) Mar 19 2009 See my reply to walter
- Don (2/7) Mar 19 2009 It breaks a lot of broken C and C++ code.
- Steve Teale (2/10) Mar 19 2009 OK, that's possibly the case, but you know that among C programmers in p...
- =?UTF-8?B?QWxleGFuZGVyIFDDoW5law==?= (4/15) Mar 19 2009 It’s just one character more in D. Really just the closing curly brack...
- Denis Koroskin (2/18) Mar 19 2009 In D, you can for(;){} :p
- BCS (4/32) Mar 19 2009 or
- Robert Fraser (3/8) Mar 19 2009 Among my top 10 D features! This has caught more bugs in my code than
- bearophile (5/6) Mar 19 2009 Such people may even start using warnings and some lint tool. And if no ...
for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?
Mar 19 2009
Thu, 19 Mar 2009 06:35:37 -0400, Steve Teale wrote:for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?for (; a<b; a++) {} is legal. I don't think that an empty statement after for is used in "a lot of code."
Mar 19 2009
Sergey Gromov wrote:for (; a<b; a++) {} is legal. I don't think that an empty statement after for is used in "a lot of code."Only in Enterprise Software!
Mar 19 2009
Hello Sergey,Thu, 19 Mar 2009 06:35:37 -0400, Steve Teale wrote:it's a trivial fix and easy to find. Heck, you hardly need to think!for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?for (; a<b; a++) {} is legal. I don't think that an empty statement after for is used in "a lot of code."
Mar 19 2009
BCS:it's a trivial fix and easy to find. Heck, you hardly need to think!And it helps to avoid other kinds of bugs quite less easy to find. I have found one of such bugs porting C code to D, the line after the for(); was meant to be looped on :-) Bye, bearophile
Mar 19 2009
BCS wrote:No, it isn't easy to find. This is in D because a colleague of mine, who was an expert C programmer (the best in the company I was working for), came to me with: for (xxx; i < 10; i++); { ... code ... } and said he could not figure out why his loop executed only and exactly once. He'd fiddled with it for a whole afternoon. He said he must be missing something obvious. I said you've got an extra ; after the ). He smacked his head and about fell over backwards. So it's illegal in D, along with: if (condition); and similar constructs. Have to use a { } to indicate a blank statement.Thu, 19 Mar 2009 06:35:37 -0400, Steve Teale wrote:it's a trivial fix and easy to find. Heck, you hardly need to think!for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?for (; a<b; a++) {} is legal. I don't think that an empty statement after for is used in "a lot of code."
Mar 19 2009
On Thu, 19 Mar 2009 20:32:54 +0300, Walter Bright <newshound1 digitalmars.com> wrote:BCS wrote:Funny enough, or programming department chief posted the following question in our corporate newsgroup: Why the hell this function enters infinite loop? void treeWalkWithoutRecursion( Node* head ) { Stack s; s.push( head ); while ( !s.empty() ); { Node* tmp = s.pop(); if ( !tmp->marked ) { if ( tmp->right ) s.push( tmp->right ); s.push( tmp ); if ( tmp->left ) s.push( tmp->left ); tmp->marked = true; } else doSomeThing( tmp ); } }No, it isn't easy to find. This is in D because a colleague of mine, who was an expert C programmer (the best in the company I was working for), came to me with: for (xxx; i < 10; i++); { ... code ... } and said he could not figure out why his loop executed only and exactly once. He'd fiddled with it for a whole afternoon. He said he must be missing something obvious. I said you've got an extra ; after the ). He smacked his head and about fell over backwards. So it's illegal in D, along with: if (condition); and similar constructs. Have to use a { } to indicate a blank statement.Thu, 19 Mar 2009 06:35:37 -0400, Steve Teale wrote:it's a trivial fix and easy to find. Heck, you hardly need to think!for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?for (; a<b; a++) {} is legal. I don't think that an empty statement after for is used in "a lot of code."
Mar 19 2009
On Thu, 19 Mar 2009 20:43:18 +0300, Denis Koroskin <2korden gmail.com> wrote:On Thu, 19 Mar 2009 20:32:54 +0300, Walter Bright <newshound1 digitalmars.com> wrote:That was less than a week ago. I'd say that this type of bugs will live as long as C++ lives.BCS wrote:Funny enough, or programming department chief posted the following question in our corporate newsgroup: Why the hell this function enters infinite loop? void treeWalkWithoutRecursion( Node* head ) { Stack s; s.push( head ); while ( !s.empty() ); { Node* tmp = s.pop(); if ( !tmp->marked ) { if ( tmp->right ) s.push( tmp->right ); s.push( tmp ); if ( tmp->left ) s.push( tmp->left ); tmp->marked = true; } else doSomeThing( tmp ); } }No, it isn't easy to find. This is in D because a colleague of mine, who was an expert C programmer (the best in the company I was working for), came to me with: for (xxx; i < 10; i++); { ... code ... } and said he could not figure out why his loop executed only and exactly once. He'd fiddled with it for a whole afternoon. He said he must be missing something obvious. I said you've got an extra ; after the ). He smacked his head and about fell over backwards. So it's illegal in D, along with: if (condition); and similar constructs. Have to use a { } to indicate a blank statement.Thu, 19 Mar 2009 06:35:37 -0400, Steve Teale wrote:it's a trivial fix and easy to find. Heck, you hardly need to think!for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?for (; a<b; a++) {} is legal. I don't think that an empty statement after for is used in "a lot of code."
Mar 19 2009
Denis Koroskin wrote:That was less than a week ago. I'd say that this type of bugs will live as long as C++ lives.The thing is, even if the programmer *intended* to put the ; there, it looks like a bug to the maintenance programmer, and he has to spend extra effort determining if it was intended or not. I doubt anyone types { } by accident.
Mar 19 2009
"Walter Bright" <newshound1 digitalmars.com> kirjoitti viestissä news:gpu1sn$sn2$1 digitalmars.com...Denis Koroskin wrote:I have a habit of indenting the semicolon on the following line, if I wanted a blank statement, like for (...; ...; ...) ; Much clearer in my opinion than having it on the same line as the for construct.That was less than a week ago. I'd say that this type of bugs will live as long as C++ lives.The thing is, even if the programmer *intended* to put the ; there, it looks like a bug to the maintenance programmer, and he has to spend extra effort determining if it was intended or not. I doubt anyone types { } by accident.
Mar 20 2009
Rioshin an'Harthen wrote:"Walter Bright" <newshound1 digitalmars.com> kirjoitti viestissäYes, that's ok, too. The only issue with it as far as working it into the language goes is then the parser and lexer do not have a clean separation - whitespace has meaning in one case.I doubt anyone types { } by accident.I have a habit of indenting the semicolon on the following line, if I wanted a blank statement, like for (...; ...; ...) ; Much clearer in my opinion than having it on the same line as the for construct.
Mar 20 2009
== Quote from Walter Bright (newshound1 digitalmars.com)'s articleRioshin an'Harthen wrote:Sounds like HTTP/HTML. The best I've come up with so far for parsing that stuff is to have the lexer actually return tokens representing whitespace in some instances. It's totally ridiculous."Walter Bright" <newshound1 digitalmars.com> kirjoitti viestissäYes, that's ok, too. The only issue with it as far as working it into the language goes is then the parser and lexer do not have a clean separation - whitespace has meaning in one case.I doubt anyone types { } by accident.I have a habit of indenting the semicolon on the following line, if I wanted a blank statement, like for (...; ...; ...) ; Much clearer in my opinion than having it on the same line as the for construct.
Mar 20 2009
Sean Kelly wrote:Sounds like HTTP/HTML. The best I've come up with so far for parsing that stuff is to have the lexer actually return tokens representing whitespace in some instances. It's totally ridiculous.When you see ad-hoc designs like that, it's obvious the designer has no experience with compilers. It's why every programmer should take a basic course in compiler design <g>.
Mar 20 2009
== Quote from Walter Bright (newshound1 digitalmars.com)'s articleSean Kelly wrote:I very much agree. In fact, I'd go so far as to say that my compiler design course was the single most valuable CS course I took while in college. It's amazing how many problems I encounter have something to do with parsing or language translation. It's also amazing how many crappy parsers there are out there for these same tasks. Clearly, compiler design doesn't get as much attention as it should in undergrad CS.Sounds like HTTP/HTML. The best I've come up with so far for parsing that stuff is to have the lexer actually return tokens representing whitespace in some instances. It's totally ridiculous.When you see ad-hoc designs like that, it's obvious the designer has no experience with compilers. It's why every programmer should take a basic course in compiler design <g>.
Mar 20 2009
Sean Kelly wrote:I very much agree. In fact, I'd go so far as to say that my compiler design course was the single most valuable CS course I took while in college. It's amazing how many problems I encounter have something to do with parsing or language translation. It's also amazing how many crappy parsers there are out there for these same tasks. Clearly, compiler design doesn't get as much attention as it should in undergrad CS.Reminds me of a metal shop class I heard about where for the first assignment each student was handed a chunk of metal and a file. His job was to file out an end wrench. The idea was to get a feel for working metal, besides developing an appreciation for what power tools do! It also filtered out the impatient, slap-dash and careless people who should never be around metal milling machines. In my high school wood shop, we were each handed a chunk of wood, a try-square, and a plane. Our job was to use the plane to create a perfectly square block. We weren't allowed to use any power tools until we passed that. I still remember the shrieks of agony from some of the students as the teacher would lay the square on it, point to a crack of light seeping under it, and pronounce "not square yet!" Good times.
Mar 20 2009
Sean Kelly wrote:== Quote from Walter Bright (newshound1 digitalmars.com)'s articleSometimes I need to have a command line UI in a program. Such programs usually have 5 to 10 commands, with their parameters. One command per line. So far I have tested and split the command line with regular expressions, because using a parser generator has felt like shooting mosquitos with a shotgun. What would your strategy be?Sean Kelly wrote:I very much agree. In fact, I'd go so far as to say that my compiler design course was the single most valuable CS course I took while in college. It's amazing how many problems I encounter have something to do with parsing or language translation. It's also amazing how many crappy parsers there are out there for these same tasks. Clearly, compiler design doesn't get as much attention as it should in undergrad CS.Sounds like HTTP/HTML. The best I've come up with so far for parsing that stuff is to have the lexer actually return tokens representing whitespace in some instances. It's totally ridiculous.When you see ad-hoc designs like that, it's obvious the designer has no experience with compilers. It's why every programmer should take a basic course in compiler design <g>.
Mar 21 2009
Georg Wrede wrote:Sometimes I need to have a command line UI in a program. Such programs usually have 5 to 10 commands, with their parameters. One command per line. So far I have tested and split the command line with regular expressions, because using a parser generator has felt like shooting mosquitos with a shotgun. What would your strategy be?If it's 5 or 10, you can get by with ad-hoc. But if you find yourself repeatedly fixing bugs in the parsing, it's time to consider a more principled approach.
Mar 21 2009
Walter Bright wrote:Georg Wrede wrote:I've found that once I created one lexer it could be re-used pretty easily for other languages too. And recursive descent parsers are trivial to write. It may be overkill for command-line parameters, but for anything remotely structured it's generally worth using.Sometimes I need to have a command line UI in a program. Such programs usually have 5 to 10 commands, with their parameters. One command per line. So far I have tested and split the command line with regular expressions, because using a parser generator has felt like shooting mosquitos with a shotgun. What would your strategy be?If it's 5 or 10, you can get by with ad-hoc. But if you find yourself repeatedly fixing bugs in the parsing, it's time to consider a more principled approach.
Mar 21 2009
Sean Kelly wrote:I've found that once I created one lexer it could be re-used pretty easily for other languages too. And recursive descent parsers are trivial to write. It may be overkill for command-line parameters, but for anything remotely structured it's generally worth using.When I was looking into parsing date strings, I thought it would be much easier if I adopted a lex/parse style approach. The result is in std.dateparse. The payoff is I've had very little trouble with it.
Mar 21 2009
Walter Bright wrote:Sean Kelly wrote:Ah, seems you can't parse dates in Nepal. Read dateparse.d, and found this in line 81: if ( year == year.init || (month < 1 || month > 12) || (day < 1 || day > 31) || (hours < 0 || hours > 23) || (minutes < 0 || minutes > 59) || (seconds < 0 || seconds > 59) || (tzcorrection != int.min && ((tzcorrection < -2300 || tzcorrection > 2300) || (tzcorrection % 10))) ) The last line here causes timezones that are not at full 10 minutes, to fail. Kathmandu, Nepal is UTC+5:45, according to Wikipedia TimeZone.I've found that once I created one lexer it could be re-used pretty easily for other languages too. And recursive descent parsers are trivial to write. It may be overkill for command-line parameters, but for anything remotely structured it's generally worth using.When I was looking into parsing date strings, I thought it would be much easier if I adopted a lex/parse style approach. The result is in std.dateparse. The payoff is I've had very little trouble with it.
Mar 23 2009
Walter Bright wrote:Sean Kelly wrote:It's a shame that this kind of lexing/parsing seems to need gotos. I always feel guilty if I put a goto in my code. (Guess I've had too stern teachers, or something...)I've found that once I created one lexer it could be re-used pretty easily for other languages too. And recursive descent parsers are trivial to write. It may be overkill for command-line parameters, but for anything remotely structured it's generally worth using.When I was looking into parsing date strings, I thought it would be much easier if I adopted a lex/parse style approach. The result is in std.dateparse. The payoff is I've had very little trouble with it.
Mar 23 2009
Georg Wrede wrote:Walter Bright wrote: (Guess I've had too stern teachers, or something...)But then in those times, when somebody said "Michael Jackson", everybody thought of structured programming, not pop-icon tragedies.
Mar 23 2009
Sean Kelly wrote:The best I've come up with so far for parsing that stuff is to have the lexer actually return tokens representing whitespace in some instances. It's totally ridiculous.The Descent port of the DMDFE lexer does this for formatting source code. It's a neat trick for formatting, but shouldn't be necessary for compilation. Also, was there ever a consensus on whether whitespace has meaning in XML?
Mar 20 2009
Reply to Walter,BCS wrote:Um, that's not what I was referring to. The problem the OP referenced seems trivial enough to me: I try to compile my translated code and get a nice error Line 3: use '{ }' for an empty statement, not a ';' I jump to that line, figure out if it was a bug in the original C code or if it is supposed to be that way and and fix itNo, it isn't easy to find. This is in D because a colleague of mine, who was an expert C programmer (the best in the company I was working for), came to me with:Thu, 19 Mar 2009 06:35:37 -0400, Steve Teale wrote:it's a trivial fix and easy to find. Heck, you hardly need to think!for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?for (; a<b; a++) {} is legal. I don't think that an empty statement after for is used in "a lot of code."
Mar 19 2009
Walter Bright Wrote:BCS wrote:I just find this scary, because although it says at the top of the page "most of this will be familiar to C/C++ programmers" this little fact means I have to go through all of the familiar constructs with a fine tooth comb. Also, nobody is answering the question. I can work out the alternatives, but I'd just prefer it if existing code worked. I used to use the idiom I quote all the time.No, it isn't easy to find. This is in D because a colleague of mine, who was an expert C programmer (the best in the company I was working for), came to me with: for (xxx; i < 10; i++); { ... code ... } and said he could not figure out why his loop executed only and exactly once. He'd fiddled with it for a whole afternoon. He said he must be missing something obvious. I said you've got an extra ; after the ). He smacked his head and about fell over backwards. So it's illegal in D, along with: if (condition); and similar constructs. Have to use a { } to indicate a blank statement.Thu, 19 Mar 2009 06:35:37 -0400, Steve Teale wrote:it's a trivial fix and easy to find. Heck, you hardly need to think!for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?for (; a<b; a++) {} is legal. I don't think that an empty statement after for is used in "a lot of code."
Mar 19 2009
Steve Teale wrote:I just find this scary, because although it says at the top of the page "most of this will be familiar to C/C++ programmers" this little fact means I have to go through all of the familiar constructs with a fine tooth comb.It shouldn't be scary, because the idea is if some common C struct is not acceptable in D, one gets a decent compiler error message. A scary thing would be if the code was silently accepted but did something different.Also, nobody is answering the question. I can work out the alternatives, but I'd just prefer it if existing code worked. I used to use the idiom I quote all the time.I'm not understanding your question, then.
Mar 19 2009
On Thu, 19 Mar 2009 22:05:21 +0300, Walter Bright <newshound1 digitalmars.com> wrote:Steve Teale wrote:I believe he is asking for a way to force that code to compile (a compiler switch or have it enabled by default).I just find this scary, because although it says at the top of the page "most of this will be familiar to C/C++ programmers" this little fact means I have to go through all of the familiar constructs with a fine tooth comb.It shouldn't be scary, because the idea is if some common C struct is not acceptable in D, one gets a decent compiler error message. A scary thing would be if the code was silently accepted but did something different.Also, nobody is answering the question. I can work out the alternatives, but I'd just prefer it if existing code worked. I used to use the idiom I quote all the time.I'm not understanding your question, then.
Mar 19 2009
On Thu, 19 Mar 2009 14:16:25 -0400, Steve Teale <steve.teale britseyeview.com> wrote:Walter Bright Wrote:BCS wrote:I just find this scary, because although it says at the top of the page "most of this will be familiar to C/C++ programmers" this little fact means I have to go through all of the familiar constructs with a fine tooth comb. Also, nobody is answering the question. I can work out the alternatives, but I'd just prefer it if existing code worked. I used to use the idiom I quote all the time.No, it isn't easy to find. This is in D because a colleague of mine, who was an expert C programmer (the best in the company I was working for), came to me with: for (xxx; i < 10; i++); { ... code ... } and said he could not figure out why his loop executed only and exactly once. He'd fiddled with it for a whole afternoon. He said he must be missing something obvious. I said you've got an extra ; after the ). He smacked his head and about fell over backwards. So it's illegal in D, along with: if (condition); and similar constructs. Have to use a { } to indicate a blank statement.Thu, 19 Mar 2009 06:35:37 -0400, Steve Teale wrote:it's a trivial fix and easy to find. Heck, you hardly need to think!for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?for (; a<b; a++) {} is legal. I don't think that an empty statement after for is used in "a lot of code."... but I'd just prefer it if existing code worked ...What D is saying, is that the existing code is likely to be wrong, and should be altered before it compiles. Besides C!=D so I don't see the problem. Gide
Mar 19 2009
BCS wrote:Hello Sergey,It's not easy to find. I didn't understand why that "for" was illegal until I saw Alexander Pánek's second answer and noticed there was a semicolon. I didn't understand why "for (; a<b; a++)" was wrong. :-PThu, 19 Mar 2009 06:35:37 -0400, Steve Teale wrote:it's a trivial fix and easy to find. Heck, you hardly need to think!for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?for (; a<b; a++) {} is legal. I don't think that an empty statement after for is used in "a lot of code."
Mar 19 2009
Reply to Ary,It's not easy to find.See my reply to walter
Mar 19 2009
Steve Teale wrote:for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?It breaks a lot of broken C and C++ code.
Mar 19 2009
Don Wrote:Steve Teale wrote:OK, that's possibly the case, but you know that among C programmers in particular there was an absolute prohibition on typing more characters than necessary.for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?It breaks a lot of broken C and C++ code.
Mar 19 2009
Steve Teale wrote:Don Wrote:It’s just one character more in D. Really just the closing curly bracket that adds up. for(;;); vs. for(;;){}Steve Teale wrote:OK, that's possibly the case, but you know that among C programmers in particular there was an absolute prohibition on typing more characters than necessary.for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?It breaks a lot of broken C and C++ code.
Mar 19 2009
On Thu, 19 Mar 2009 19:58:48 +0300, Alexander Pánek <alexander.panek brainsware.org> wrote:Steve Teale wrote:In D, you can for(;){} :pDon Wrote:It’s just one character more in D. Really just the closing curly bracket that adds up. for(;;); vs. for(;;){}Steve Teale wrote:OK, that's possibly the case, but you know that among C programmers in particular there was an absolute prohibition on typing more characters than necessary.for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?It breaks a lot of broken C and C++ code.
Mar 19 2009
Reply to Denis,On Thu, 19 Mar 2009 19:58:48 +0300, Alexander Pánek <alexander.panek brainsware.org> wrote:or int i; for(if(i%2) i++; i< 10; i++) {}Steve Teale wrote:In D, you can for(;){} :pDon Wrote:It's just one character more in D. Really just the closing curly bracket that adds up. for(;;); vs. for(;;){}Steve Teale wrote:OK, that's possibly the case, but you know that among C programmers in particular there was an absolute prohibition on typing more characters than necessary.for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?It breaks a lot of broken C and C++ code.
Mar 19 2009
Steve Teale wrote:for (; a<b; a++); is illegal in D. Doesn't this break a lot of C and C++ code?Among my top 10 D features! This has caught more bugs in my code than any "warning"s have in any other language (I do that a lot...).
Mar 19 2009
Denis Koroskin:I'd say that this type of bugs will live as long as C++ lives.<Such people may even start using warnings and some lint tool. And if no lint tool that currently exists is able to warn about those bugs (and I seriously doubt this) then it's time to fix/create a C++ lint able to do this too. On the other hand what you say suggests me that the usage of lint tools isn't so widespread, so it may be good to add the D compiler/language some of the basic lint-like functionality I was talking for. I'll keep asking for some of such features. Bye, bearophile
Mar 19 2009