Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > bugs in c

Reply
Thread Tools

bugs in c

 
 
Irrwahn Grausewitz
Guest
Posts: n/a
 
      10-15-2003
Joona I Palaste <(E-Mail Removed)> wrote:

>Arthur J. O'Dwyer <(E-Mail Removed)> scribbled the following:
>
>> Moral: Design well, and design early, because once a re-design
>> becomes a good idea, it's no longer a good idea.

>
>So now the rule of thumb when dealing with C operator precedence is:
>"If in doubt, use parantheses like they're going out of fashion."


Good advice. Both.
--
Irrwahn
((E-Mail Removed))
 
Reply With Quote
 
 
 
 
August Derleth
Guest
Posts: n/a
 
      10-15-2003
"Robert Stankowic" <(E-Mail Removed)> wrote in message news:<3f8d046d$0$33850$(E-Mail Removed) ay.telekom.at>...
> (you know, that features of a language which provide
> enough ammunition to shoot yourself into your foot)


Shoot myself into my own foot? That would be a neat trick! Wouldn't it
involve infinite recursion, tho?
 
Reply With Quote
 
 
 
 
CBFalconer
Guest
Posts: n/a
 
      10-16-2003
Joona I Palaste wrote:
>

.... snip ...
>
> So now the rule of thumb when dealing with C operator precedence is:
> "If in doubt, use parantheses like they're going out of fashion."


I make it a practice to use Lots of Insipid Silly Parentheses.
The only assumptions I make is that multiplicative has precedence
of additive has precedence over logical operators.

This avoids much wear on tear on the little grey cells.

--
Chuck F ((E-Mail Removed)) ((E-Mail Removed))
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!


 
Reply With Quote
 
Nudge
Guest
Posts: n/a
 
      10-16-2003
> The only assumptions I make is that multiplicative has precedence
> of additive has precedence over logical operators.
>
> This avoids much wear on tear on the little grey cells.


Judging from your first sentence, I'm afraid the little grey cells
have taken quite a beating over the years.

Just kidding, of course ;-

 
Reply With Quote
 
Dan Pop
Guest
Posts: n/a
 
      10-16-2003
In <bmk924$dql$(E-Mail Removed)> Joona I Palaste <(E-Mail Removed)> writes:

>Arthur J. O'Dwyer <(E-Mail Removed)> scribbled the following:
>> What would C99 have done? Changed the precedence tables? Do
>> you have *any* idea how confusing that would be, especially when
>> some hapless newbie Googles "c precedence table" and finds that
>> the top two results contradict each other? Not to mention the
>> vast body of C89 code out there that would break if the precedences
>> were changed, or the annoyance it would cause to the designers of
>> C-like languages like C++, Java, et al. - which of the two precedence
>> tables would *they* use now?

>
>> Moral: Design well, and design early, because once a re-design
>> becomes a good idea, it's no longer a good idea.

>
>So now the rule of thumb when dealing with C operator precedence is:
>"If in doubt, use parantheses like they're going out of fashion."


But that's the very problem: there is very little doubt in the mind of a
newbie about the meaning of (alpha & 0xff == 0x33), therefore he can
see no need for the *necessary* extra parentheses.

As such, the expression is practically useless because it is parsed as
(alpha & (0xff == 0x33)) which has no good use I can think of.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Dan Pop
Guest
Posts: n/a
 
      10-16-2003
In <(E-Mail Removed)> CBFalconer <(E-Mail Removed)> writes:

>I make it a practice to use Lots of Insipid Silly Parentheses.
>The only assumptions I make is that multiplicative has precedence
>of additive has precedence over logical operators.
>
>This avoids much wear on tear on the little grey cells.

^^^^^^^^^^^^^^^^^^^^^
OTOH, leave them idle and they immediately get rusty. Which could
explain your repeated failures of getting them to work when you needed
them

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: (E-Mail Removed)
 
Reply With Quote
 
Richard Bos
Guest
Posts: n/a
 
      10-16-2003
Joona I Palaste <(E-Mail Removed)> wrote:

> So now the rule of thumb when dealing with C operator precedence is:
> "If in doubt, use parantheses like they're going out of fashion."


Hmmm... no. I find the precedence of C operators quite sensible, with
some glaring exceptions. Those exceptions are the bitwise operators,
which are wrong; and the shift operators, and the relative positions of
the ternary and assignment operators, for which no solution is
definitely right. Around them, I parenthesise. Around the others, I
don't see why it would be necessary.
And I'll remark that your rule of thumb would mean that many people
would follow fashion and stop using parentheses at all...

Richard
 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      10-16-2003
Dan Pop <(E-Mail Removed)> spoke thus:

> As such, the expression is practically useless because it is parsed as
> (alpha & (0xff == 0x33)) which has no good use I can think of.


Maybe for setting an element in a bit array only if a given condition is true?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
 
Reply With Quote
 
Dik T. Winter
Guest
Posts: n/a
 
      10-16-2003
In article <bmm1n1$gmi$(E-Mail Removed)> Christopher Benson-Manica <(E-Mail Removed)> writes:
> Dan Pop <(E-Mail Removed)> spoke thus:
>
> > As such, the expression is practically useless because it is parsed as
> > (alpha & (0xff == 0x33)) which has no good use I can think of.

>
> Maybe for setting an element in a bit array only if a given condition is true?


Perhaps clearing all bits, except one if the condition is true? The
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
 
Reply With Quote
 
Dan Pop
Guest
Posts: n/a
 
      10-16-2003
In <(E-Mail Removed)> "Dik T. Winter" <(E-Mail Removed)> writes:

>In article <bmm1n1$gmi$(E-Mail Removed)> Christopher Benson-Manica <(E-Mail Removed)> writes:
> > Dan Pop <(E-Mail Removed)> spoke thus:
> >
> > > As such, the expression is practically useless because it is parsed as
> > > (alpha & (0xff == 0x33)) which has no good use I can think of.

> >
> > Maybe for setting an element in a bit array only if a given condition is true?

>
>Perhaps clearing all bits, except one if the condition is true? The


That's why I said "good use". Hypothetical uses can be found, of course.

How many people have actually used this construct, *on purpose*, in a real
program?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: (E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bugs and Bugs...get rid of them Jason Computer Security 1 01-31-2006 10:47 PM
BUGS ??? erha Wireless Networking 7 05-16-2005 02:34 PM
Still use 'ruby-bugs' for Ruby bugs? Josef 'Jupp' Schugt Ruby 2 11-04-2004 10:10 PM
Firefox 0.9.1 major bugs Jonathan Firefox 7 07-07-2004 11:28 PM
mozilla community (bugs) - how it works? SiD` Firefox 1 05-25-2004 02:44 PM



Advertisments