December 07, 2005 Re: About DM's Warnings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Derek Parnell wrote: > I believe that Walter is philosophically opposed to the concept of > 'warning'. Basically, if something is worth warning you about, it is worth > fixing. So in effect there is nothing different between a warning and an > error. And he doesn't really mumble about it, either... :-) http://www.digitalmars.com/d/overview.html: (No Warnings) "D compilers will not generate warnings for questionable code. Code will either be acceptable to the compiler or it will not be. This will eliminate any debate about which warnings are valid errors and which are not, and any debate about what to do with them. The need for compiler warnings is symptomatic of poor language design." http://www.digitalmars.com/d/warnings.html (Warnings as Lint) "Depending on one's point of view, warnings are either a symptom of broken language design or a useful 'lint' like tool to analyze code and look for potential trouble spots. Most of the time, those trouble spots will be legitimate code intended to be that way. More rarely, it may indicate an unintentional error on the part of the programmer." and "Warnings are not a defined part of the D Programming Language. They exist at the discretion of the compiler vendor, and will most likely vary from vendor to vendor. All constructs for which an implementation may generate a warning message are legal D code." **** I still think DMD's Phobos should compile with -w, though ? I've patched it do so before, and it could be done again... (then again, I tend to use "use strict;" and "-Wall -Werror" when developing... Not for deployment though, to be portable) Last time I used it for Phobos, I found two *real* bugs within. And that's the reason why I put up with the sometimes annoying warnings. It's tedious to do the first time, but then it's done ? i.e. by working around the known warnings, I find the "unknown" - even if it means adding an extra cast or an extra parenthesis... Like with Unit Tests, once you get bitten - it's hard to go back ? --anders |
December 07, 2005 Re: About DM's Warnings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | Anders F Björklund schrieb: > Derek Parnell wrote: > >> I believe that Walter is philosophically opposed to the concept of 'warning'. Basically, if something is worth warning you about, it is worth fixing. So in effect there is nothing different between a warning and an error. > > And he doesn't really mumble about it, either... :-) > > http://www.digitalmars.com/d/overview.html: (No Warnings) > "D compilers will not generate warnings for questionable code. Code will > either be acceptable to the compiler or it will not be. Well, my initial question was not about questionable code... It was about variables that are defined but not used - doesn't mean that the program has a bug. > This will eliminate any debate about which warnings are valid errors and which are > not, and any debate about what to do with them. The need for compiler warnings is symptomatic of poor language design." I also don't think this (in particular) has anything to do with language design, which is very fine in this case, but with the practical usage of the language! Everyone forgets something now and then, right? > http://www.digitalmars.com/d/warnings.html (Warnings as Lint) "Depending on one's point of view, warnings are either a symptom of broken language design or a useful 'lint' like tool to analyze code and look for potential trouble spots. Most of the time, those trouble spots will be legitimate code intended to be that way. More rarely, it may indicate an unintentional error on the part of the programmer." In the case of unused variable you could argue that this has happen because the "user" forgot to remove an auxiliary variable that was previously used for debugging! Has zero to do with "broken language design"! > and > "Warnings are not a defined part of the D Programming Language. > They exist at the discretion of the compiler vendor, and will most > likely vary from vendor to vendor. All constructs for which an > implementation may generate a warning message are legal D code." > It happens many times that, while coding, I forget to remove some variable declarations and the code is so huge that it is difficult to track down and remove them. Well, if the compiler removes the variables anyway, there should be no real problem but... wouldn't it make the code much cleaner not having "junk" in the code? Well, if Walter thinks warnings are useless, then let it be - I'm not an expert in writting compilers anyways. I just thought that in this case it would be a good idea that the compiler could "help" to cleanup the code! :) Best, Tiago -- Tiago Gasiba (M.Sc.) - http://www.gasiba.de Everything should be made as simple as possible, but not simpler. |
December 08, 2005 Re: About DM's Warnings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | Anders F Björklund wrote: > Derek Parnell wrote: > >> I believe that Walter is philosophically opposed to the concept of >> 'warning'. Basically, if something is worth warning you about, it is worth >> fixing. So in effect there is nothing different between a warning and an >> error. > > > And he doesn't really mumble about it, either... :-) > > http://www.digitalmars.com/d/overview.html: (No Warnings) > "D compilers will not generate warnings for questionable code. Code will > either be acceptable to the compiler or it will not be. This will > eliminate any debate about which warnings are valid errors and which are > not, and any debate about what to do with them. The need for compiler > warnings is symptomatic of poor language design." > > http://www.digitalmars.com/d/warnings.html (Warnings as Lint) > "Depending on one's point of view, warnings are either a symptom of > broken language design or a useful 'lint' like tool to analyze code and > look for potential trouble spots. Most of the time, those trouble spots > will be legitimate code intended to be that way. More rarely, it may > indicate an unintentional error on the part of the programmer." > and > "Warnings are not a defined part of the D Programming Language. > They exist at the discretion of the compiler vendor, and will most > likely vary from vendor to vendor. All constructs for which an > implementation may generate a warning message are legal D code." > > **** > > I still think DMD's Phobos should compile with -w, though ? > > I've patched it do so before, and it could be done again... > (then again, I tend to use "use strict;" and "-Wall -Werror" > when developing... Not for deployment though, to be portable) > > Last time I used it for Phobos, I found two *real* bugs within. > And that's the reason why I put up with the sometimes annoying > warnings. It's tedious to do the first time, but then it's done ? > i.e. by working around the known warnings, I find the "unknown" - > even if it means adding an extra cast or an extra parenthesis... > Like with Unit Tests, once you get bitten - it's hard to go back ? > > --anders With all those inconsistent statements, I'm not sure exactly what Walter's opinion is now, but anyway let me say this. Again I say that many "warnings" should be treated as errors, but *not* those two I mentioned before. Let me give a practical example. Sometimes I want to run some test runs of my program, each with certain code pieces commented out (or made inacessible by an early /return/). Now, this usually causes unused variable or unreachable code warnings, and that's annoying because you will have to comment out the other parts of the code too (and possibly comment them back in afterwards). I've seen this annoyance first hand in the Java projects I've been in (because Java does threat these conditions as errors, not just as warnings), altough fortunately this did not happen often in those Java projects (perhaps due to their natures). However, in the C/C++ projects I've been in, these cases happened quite often[*] , and I know it would be a major pain to have these conditions treated as errors when I was developing them. [*] hum.. wonder if perhaps due to their nature being graphical-interactive (opengl, etc.). -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural." |
December 08, 2005 Re: About DM's Warnings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bruno Medeiros | This is why I don't use warnings, because I need to 'fix' them if I want to see more. It just isn't worth it, unless you feel a need to fix every single warning you get.
Bruno Medeiros wrote:
> Walter Bright wrote:
>
>> "Tiago Gasiba" <tiago.gasiba@gmail.com> wrote in message
>> news:dn1611$grl$1@digitaldaemon.com...
>>
>>> "dmd -w" on the following code should produce a warning like "unused
>>
>>
>> variable ii" or similar.
>>
>>> Usually helps a lot :)
>>>
>>> <snip>
>>> int main(){
>>> int ii;
>>>
>>> return 0;
>>> }
>>> <snip>
>>
>>
>>
>> This isn't a bug, it's by design <g>. Warnings about unused variables can
>> get rather annoying when they're intended.
>>
>>
>
> Why is it that Digital Mars compiler's option to enable warnings does not only warning-notification but also error-on-warning? And there isn't even a way to do just the first?
> In *all* compilers I've seen so far, (gcc, javac/JDT, VS C++, VS C#, etc., and maybe some more I don't recall) the warning semantics are all the same: by default "notify" about warnings, and only with an extra option do the warnings cause a compilation error/stop.
>
> This is what makes more sense in terms of nomenclature, because if a "warning" if allways an error, then it is not a "warning", it is a... well, "prohibition" or "order" or something...
>
> But more importantly, it is also what makes more sense in terms of programming/development, because it is more useful to have no-error warnings, allways enabled. Otherwise, no wonder one finds DM's warnings about unused variable annoying (as well as other warnings), since they halt compilation in unwanted situations. The end result is the coder rarely compiling with -w , is it not?
>
> I do agree that some of the traditional warnings (specially in the C/C++ world), such as use-of-uninitialized-variable, could be treated allways as errors, as they probably signify wrong code.
> However, some other types of warnings, such as unused-variable, unreachable-code, etc., are pretty much innocuous, and they occur frequently and *naturally* during developing/testing, where often there is incomplete code. That's why it is a royal pain to have error-on-warning enabled as such.
>
|
December 08, 2005 Re: About DM's Warnings | ||||
---|---|---|---|---|
| ||||
Posted in reply to clayasaurus | On Wed, 07 Dec 2005 19:45:33 -0500, clayasaurus wrote: > This is why I don't use warnings, because I need to 'fix' them if I want to see more. It just isn't worth it, unless you feel a need to fix every single warning you get. And I do. -- Derek (skype: derek.j.parnell) Melbourne, Australia "A learning experience is one of those things that says, 'You know that thing you just did? Don't do that.'" - D.N. Adams 8/12/2005 11:54:51 AM |
December 08, 2005 Re: About DM's Warnings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tiago Gasiba | Tiago Gasiba wrote:
> Well, if Walter thinks warnings are useless, then let it be - I'm not an expert in writting compilers anyways. I just thought that in this case it
> would be a good idea that the compiler could "help" to cleanup the code! :)
I agree. But I think, we don't necessarily want to call it a warning. It's another 'code cleanup' tool, like the new code coverage option,
which you can use to improve the quality of your code before you release it. It's yet another action the compiler can easily perform using its built-in parser. (Actually, this one is almost a 'code coverage of declarations).
dmd -w -style main.d
|
December 08, 2005 Re: About DM's Warnings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bruno Medeiros | Bruno Medeiros wrote:
> With all those inconsistent statements, I'm not sure exactly what Walter's opinion is now, but anyway let me say this. Again I say that many "warnings" should be treated as errors, but *not* those two I mentioned before.
Maybe I should have mentioned this more explicitly, but quite some
time did pass between those two quotes. Walter did add some warnings
to DMD (due to popular demand?), but the "warning = error" still stands
as far as I can tell. The option given is whether to check, or not... ?
So it's more of a extra "lint run", than giving extra diagnostic output.
(again to emphasise: this is how it works in DMD - not how it "must be")
And I agree that having a "continue on error" option available can be
highly useful, especially in early development or when porting old code.
But it also feels like that we went over all this earlier with regard
to how UnitTest-runs work*, without coming to much of a "consensus"...
So I don't think that the default behaviour is going to change much.
Hopefully it can be added as an *option* (like: "make -k" ?), though.
--anders
*
i.e. whether the first error should stop the testing, or if it should
continue with the other tests too and collect and log a test summary ?
|
December 08, 2005 Re: About DM's Warnings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tiago Gasiba | Tiago Gasiba wrote: > Well, if Walter thinks warnings are useless, then let it be - I'm not an expert in writting compilers anyways. I just thought that in this case it > would be a good idea that the compiler could "help" to cleanup the code! :) > I don't think I'd ever tell Walter how to write a compiler, but this is not about writing compilers (as in implementating compilers), it's about using compilers. And in using compilers (and using languages) we are all somewhat experienced and it's something we can discuss about :) -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural." |
December 08, 2005 Re: About DM's Warnings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Derek Parnell wrote: > On Wed, 07 Dec 2005 19:45:33 -0500, clayasaurus wrote: > > >>This is why I don't use warnings, because I need to 'fix' them if I want to see more. It just isn't worth it, unless you feel a need to fix every single warning you get. > > > And I do. > For a release, yes, definitely. But during development too?, all the time? -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural." |
December 08, 2005 Re: About DM's Warnings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | Anders F Björklund wrote: > Bruno Medeiros wrote: > > So I don't think that the default behaviour is going to change much. > Hopefully it can be added as an *option* (like: "make -k" ?), though. > I don't really mind much what the default behaviour is, just having the option would be fine by me. > > But it also feels like that we went over all this earlier with regard > to how UnitTest-runs work*, without coming to much of a "consensus"... > > * > i.e. whether the first error should stop the testing, or if it should > continue with the other tests too and collect and log a test summary ? > Hum.. indeed, there are quite some things that could be said about this... -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural." |
Copyright © 1999-2021 by the D Language Foundation