|
From: Greg Herlihy on 5 May 2008 00:52 On May 4, 6:18 pm, Ian Collins <ian-n...(a)hotmail.com> wrote: > > gcc -Wall -pedantic -ansi basic.c script.c -lm > basic.c: In function 'dofor': > basic.c:870: warning: suggest parentheses around && within || > basic.c:873: warning: suggest parentheses around assignment used as > truth value > basic.c: In function 'getdimvar': > basic.c:1932: warning: suggest parentheses around assignment used as > truth value These warnings are bogus. It is bad form to insert parentheses where none are needed in an expression. Unnecessary parentheses simply highlight the fact that the programmer does must know the order in which the operators will be evaluated - and therefore has to rely on parentheses to make up for a deficit of knowledge. Greg
From: Greg Herlihy on 5 May 2008 00:58 On May 4, 6:18 pm, Ian Collins <ian-n...(a)hotmail.com> wrote: > Richard Heathfield wrote: > > Ian Collins said: > > >> Bartc wrote: > >>> "Richard Heathfield" <r...(a)see.sig.invalid> wrote in message > >>>news:lNydndtwTovn1oPVnZ2dnUVZ8rOdnZ2d(a)bt.com... > > > <snip> > > >>>> Even after dealing with those two issues, however, compilation reports > >>>> 32 remaining problems with the code. > > >>>> Sorry, but I don't have time to wade through them all. > >>> I tried 3 different compilers in 5 minutes. 2-3 warnings each but all > >>> generated a working executable. No mods needed. > > >> Same here, he must be hallucinating. > > > Yes, that must be it. I must be hallucinating. And so, presumably, is gcc. > > gcc -Wall -pedantic -ansi basic.c script.c -lm > basic.c: In function 'dofor': > basic.c:870: warning: suggest parentheses around && within || > basic.c:873: warning: suggest parentheses around assignment used as > truth value > basic.c: In function 'getdimvar': > basic.c:1932: warning: suggest parentheses around assignment used as > truth value These warnings are bogus. It is bad form to insert parentheses where none are needed in an expression. Unnecessary parentheses in an expression simply highlight the fact that the programmer must not know the order in which the operators will be evaluated - and therefore has to rely on parentheses to make up for a deficit in knowledge. Greg
From: Richard Heathfield on 5 May 2008 01:11 Greg Herlihy said: > On May 4, 6:18 pm, Ian Collins <ian-n...(a)hotmail.com> wrote: >> >> gcc -Wall -pedantic -ansi basic.c script.c -lm >> basic.c: In function 'dofor': >> basic.c:870: warning: suggest parentheses around && within || >> basic.c:873: warning: suggest parentheses around assignment used as >> truth value >> basic.c: In function 'getdimvar': >> basic.c:1932: warning: suggest parentheses around assignment used as >> truth value > > These warnings are bogus. Without looking anything up, please parenthesise this line in such a way as not to change its meaning: if(stepval < 0 && initval < toval || stepval > 0 && initval > toval) After you've done that, you can look stuff up to see whether you got it right. If you did get it right, award yourself a pat on the back, and consider the fact that not every C programmer is sufficiently skilled to follow the above expression properly. > It is bad form to insert parentheses where none are needed in an > expression. I tend to agree, but I also think it's bad form to chain ANDs and ORs together like that. *Either* parenthesise *or* split the line up. For example: negstep = stepval < 0 && initval < toval; posstep = stepval > 0 && initval > toval; if(negstep || posstep) The warning (for Malcolm's newbie-scaring if) rightly points up the fact that the line is badly written and should be fixed. You don't have to take its advice on /how/ to fix it, but IMHO the fact that the line is being diagnosed is not bogus at all. -- Richard Heathfield <http://www.cpax.org.uk> Email: -http://www. +rjh@ Google users: <http://www.cpax.org.uk/prg/writings/googly.php> "Usenet is a strange place" - dmr 29 July 1999
From: Malcolm McLean on 5 May 2008 04:31 "Bartc" <bc(a)freeuk.com> wrote in message > > * It is very slow (on one brief test, 40x slower than Python, itself not > known for it's speed) > I've got a much faster semi-compiled version. However I haven't released it. The problem it it is that much more difficult to modify to add your own functions. > > * The language is very primitive, even for Basic. > > Has this ever been commented on? > Again, you could add procedures, but this creates major complications. -- Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm
From: rossum on 5 May 2008 04:58 On Sun, 4 May 2008 21:58:33 -0700 (PDT), Greg Herlihy <greghe(a)mac.com> wrote: >On May 4, 6:18�pm, Ian Collins <ian-n...(a)hotmail.com> wrote: >> Richard Heathfield wrote: >> > Ian Collins said: >> >> >> Bartc wrote: >> >>> "Richard Heathfield" <r...(a)see.sig.invalid> wrote in message >> >>>news:lNydndtwTovn1oPVnZ2dnUVZ8rOdnZ2d(a)bt.com... >> >> > <snip> >> >> >>>> Even after dealing with those two issues, however, compilation reports >> >>>> 32 remaining problems with the code. >> >> >>>> Sorry, but I don't have time to wade through them all. >> >>> I tried 3 different compilers in 5 minutes. 2-3 warnings each but all >> >>> generated a working executable. No mods needed. >> >> >> Same here, he must be hallucinating. >> >> > Yes, that must be it. I must be hallucinating. And so, presumably, is gcc. >> >> gcc -Wall -pedantic -ansi basic.c script.c -lm >> basic.c: In function 'dofor': >> basic.c:870: warning: suggest parentheses around && within || >> basic.c:873: warning: suggest parentheses around assignment used as >> truth value >> basic.c: In function 'getdimvar': >> basic.c:1932: warning: suggest parentheses around assignment used as >> truth value > >These warnings are bogus. It is bad form to insert parentheses where >none are needed in an expression. Unnecessary parentheses in an >expression simply highlight the fact that the programmer must not know >the order in which the operators will be evaluated - and therefore has >to rely on parentheses to make up for a deficit in knowledge. Or alternatively the programmer has decided to make life easier for the undertrained maintenance programmers who will follow her in maintaining the code. A few extra parentheses can make code clearer and easier to maintain. rossum >Greg > >
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: misc: how random is 'random'?... Next: Record stack back traces efficiently on space |