D - unused labels should cause an error
- Robert (3/3) Dec 08 2003 I suggest that unused labels should cause an error.
- Walter (8/10) Dec 08 2003 I understand what you're saying. The problem with it, though, is that th...
- Matthew Wilson (6/14) Dec 08 2003 Absolutely not. Your ability to flabbergast me on this issue has just
- Walter (12/28) Dec 09 2003 the
- Robert (7/38) Dec 09 2003 Hmm. Though I think goto isn't a good example,
- Richard Krehbiel (6/17) Dec 09 2003 I have myself coded the infamous "defualt:" goto-label, only to have my
- J C Calvarese (7/32) Dec 09 2003 For me, using an editor that does syntax highlighting can help avoid
- Juan C. (18/28) Dec 09 2003 Another solution to a mispelled default looking like a label is my idea ...
I suggest that unused labels should cause an error. This prevents bugs due to typos of `default' label. Robert (Japanese)
Dec 08 2003
"Robert" <Robert_member pathlink.com> wrote in message news:br1r2o$19i0$1 digitaldaemon.com...I suggest that unused labels should cause an error. This prevents bugs due to typos of `default' label.I understand what you're saying. The problem with it, though, is that the label may be a target of a goto from inside a version statement elsewhere in the function. Wrapping the label in another version winds up looking kinda ugly. The default typo bug is alleviated somewhat by the language inserting a default:assert(0); if no other default is supplied.
Dec 08 2003
inI suggest that unused labels should cause an error. This prevents bugs due to typos of `default' label.I understand what you're saying. The problem with it, though, is that the label may be a target of a goto from inside a version statement elsewherethe function. Wrapping the label in another version winds up looking kinda ugly. The default typo bug is alleviated somewhat by the language inserting a default:assert(0); if no other default is supplied.Absolutely not. Your ability to flabbergast me on this issue has just expanded its borders. If the typo issue isn't compelling evidence in favour of a mandatory default, I can't conceive of what will be. :(
Dec 08 2003
"Matthew Wilson" <matthew.hat stlsoft.dot.org> wrote in message news:br3klk$uuk$1 digitaldaemon.com...theI suggest that unused labels should cause an error. This prevents bugs due to typos of `default' label.I understand what you're saying. The problem with it, though, is thatelsewherelabel may be a target of a goto from inside a version statementinkindathe function. Wrapping the label in another version winds up lookingfavourugly. The default typo bug is alleviated somewhat by the language inserting a default:assert(0); if no other default is supplied.Absolutely not. Your ability to flabbergast me on this issue has just expanded its borders. If the typo issue isn't compelling evidence inof a mandatory default, I can't conceive of what will be. :(I didn't try the compilers) are unreferenced labels an error. I'm not doesn't seem to be any consistent view in the C-like-language programming community how switch and labels ought to work.
Dec 09 2003
Hmm. Though I think goto isn't a good example, the problem may occur when labeled break is used. I back it down. ...since I've never done the typo, ...no, I think now that this problem should be solved by other way (e.g. improving switch statement syntax itself.) In article <br417o$1iea$1 digitaldaemon.com>, Walter says..."Matthew Wilson" <matthew.hat stlsoft.dot.org> wrote in message news:br3klk$uuk$1 digitaldaemon.com...Robert (Japanese)theI suggest that unused labels should cause an error. This prevents bugs due to typos of `default' label.I understand what you're saying. The problem with it, though, is thatelsewherelabel may be a target of a goto from inside a version statementinkindathe function. Wrapping the label in another version winds up lookingfavourugly. The default typo bug is alleviated somewhat by the language inserting a default:assert(0); if no other default is supplied.Absolutely not. Your ability to flabbergast me on this issue has just expanded its borders. If the typo issue isn't compelling evidence inof a mandatory default, I can't conceive of what will be. :(I didn't try the compilers) are unreferenced labels an error. I'm not doesn't seem to be any consistent view in the C-like-language programming community how switch and labels ought to work.
Dec 09 2003
Walter wrote:"Robert" <Robert_member pathlink.com> wrote in message news:br1r2o$19i0$1 digitaldaemon.com...I have myself coded the infamous "defualt:" goto-label, only to have my default case ignored. Then, I spent a day looking at the code and not seeing the misspelling. My own thought was to spell it "case default:" rather than just "default:" to make the difference more obvious.I suggest that unused labels should cause an error. This prevents bugs due to typos of `default' label.I understand what you're saying. The problem with it, though, is that the label may be a target of a goto from inside a version statement elsewhere in the function. Wrapping the label in another version winds up looking kinda ugly.
Dec 09 2003
Richard Krehbiel wrote:Walter wrote:For me, using an editor that does syntax highlighting can help avoid this kind of error. YMMV. (Of course, if I haven't made any stupid programming mistakes recently, it's because I haven't worked on any programs recently.) Justin"Robert" <Robert_member pathlink.com> wrote in message news:br1r2o$19i0$1 digitaldaemon.com...I have myself coded the infamous "defualt:" goto-label, only to have my default case ignored. Then, I spent a day looking at the code and not seeing the misspelling.I suggest that unused labels should cause an error. This prevents bugs due to typos of `default' label.I understand what you're saying. The problem with it, though, is that the label may be a target of a goto from inside a version statement elsewhere in the function. Wrapping the label in another version winds up looking kinda ugly.My own thought was to spell it "case default:" rather than just "default:" to make the difference more obvious.
Dec 09 2003
Another solution to a mispelled default looking like a label is my idea for a new switch statement (as mentioned before) wherein the braces of a case are required... switch expr { case x { } // no code allowed here default { } } not only does this form of switch/case _not_ have a colon (and therefore not look like a label), but no code (and therefore no labels) are allowed within the switch but outside a case. And of course I don't want fall-through, but that's another matter. :) In article <br3gdl$pan$1 digitaldaemon.com>, Walter says..."Robert" <Robert_member pathlink.com> wrote in message news:br1r2o$19i0$1 digitaldaemon.com...I suggest that unused labels should cause an error. This prevents bugs due to typos of `default' label.I understand what you're saying. The problem with it, though, is that the label may be a target of a goto from inside a version statement elsewhere in the function. Wrapping the label in another version winds up looking kinda ugly. The default typo bug is alleviated somewhat by the language inserting a default:assert(0); if no other default is supplied.
Dec 09 2003