Re: man 3 switch



On 11/16/09 13:54, quoth Rick Stevens:
On 11/14/2009 01:55 PM, Frank Cox wrote:
On Sat, 14 Nov 2009 14:50:57 -0500
Steven W. Orr wrote:

There's nothing wrong with perl having all kinds of perldoc pages.
But perl
comes from one place. C, OTOH could come from lots of places besides
FSF and
the switch statement in gcc may not be exactly the same as the switch
statement in some other dialect.

As C is an ISO standard, I sincerely doubt there would be any
difference in the
syntax and behaviour of the keywords between C compilers on any Unix-like
operating system.

Incorrect. C, for example, does not guarantee the order of evaluation
of arithmetic operators of equal precedence in the same statement (in
other words, is something like "a + b + c" evaluated left to right, or
right to left?). This can have significant effects if some of the
operands have "side effects"

Another example is that a null pointer (or the value "NUL") is not
necessarily zero, only that it is guaranteed to not point at any valid
datum.

C allows quite a bit of leeway to the compiler implementation.


I think I disagree on this one. We jumped from standardization of keywords to
how operators perform. I quote from page 53 of K&R: Table of Precedence and
Associativity of Operators: a + b + c *always* goes from left to right. K&R is
not the standard, but does the standard say otherwise? Lots of things are up
to the compiler writer, but I'd be surprised if this was one of them. Sometime
people worry about things like

a++ + b++ + c++

but even there, the precedence and the associativity are defined. In this case

a++ + b++ + c++

becomes (in psuedo stack code):

a++
b++
c++
a b +
c +

because binary + is lower precedence than ++.

No?

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net

Attachment: signature.asc
Description: OpenPGP digital signature

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Relevant Pages

  • Re: man 3 switch
    ... the switch statement in gcc may not be exactly the same as the switch ... As C is an ISO standard, I sincerely doubt there would be any ... of arithmetic operators of equal precedence in the same statement (in ... increment the value of a, ...
    (Fedora)
  • Re: Function call evaluation order
    ... How do you propose to explain in terms of precedence and associativity the ... Your expectations have been tuned to match what your compiler does! ... Undefined behavior is behavior that is not defined by the C++ standard. ...
    (microsoft.public.vc.language)
  • Re: Sequence points
    ... consecutive sequence points with respect to ordinary operations tracks ... follow operator precedence. ... determined, even before the standard, was inadequate based on my prior ... They are engaged in mail fraud, ...
    (comp.programming)
  • Re: man 3 switch
    ... of arithmetic operators of equal precedence in the same statement (in ... not the standard, but does the standard say otherwise? ... The languages themselves normally aren't. ...
    (Fedora)
  • Re: C/C++ Ambiguity in Order of Evaluation
    ... The order of evaluation of subexpressions is determined by the ... precedence and grouping of the operators. ... A reference manual that implements a language standard should be as ... settled in other manner that do not cause confusion. ...
    (comp.lang.c)