Re: this girl calls c ugly

Liste des GroupesRevenir à cl c  
Sujet : Re: this girl calls c ugly
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.c
Date : 29. May 2026, 17:10:35
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <10vcdpr$3uus8$3@dont-email.me>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
On 2026-05-29 13:19, Bart wrote:
How about:
Generally; if in doubt you can always inspect the precedence
table that you find in K&R and elsewhere. Below some hints to
hopefully reduce your confusion...

 * What is the order here: a ^ b | c
Personally I don't think that there's a prevalent definition
how these should be ordered. - But note the history of these
operators, which was BTW why they are in "C" at the positions
that they are; their (potential) use as boolean sets.
To memorize the bit-value operations you can associate them
with the glyphs for the boolean operations; per convention
AND (&&) comes before OR (||), and insert the bitwise xor in
between. - As said; there's a rationale for the choice, and
a historic explanation (that makes sense), but you can in
case of doubt or to make things clearer also use parentheses.

 * Why do bitwise & | ^ need their own level anyway
For historic reasons of potential use. (As said above.)

 * What is most intuitive precedence here: a << 3 + b, and what
   is it in C
What it is in "C" you should look up in the precedence table.
What it is intuitively depends on what the programmer wanted to
express. As it is written a shift by a calculated expression
seems have been the intention, and that's also how "C" handles
that.
Why would one who intends to say: make space for three bits in
'a' to put there the bit-pattern stored in 'b'? If I'd wanted to
express that I'd use a binary '|', and because or the well known
precedence I'd have no parenthesis around, as in  a << 3 | b .
Of course there's also the potential semantics that you have a
'b' that exceeds three bit and you want to have that added to the
shifted value of 'a'. But then I'd not use bit-value operations
to express that but the clear and more appropriate  a * 8 + b .
Both semantics bit-op and int-arithmetic don't need parenthesis
in "C" because of its clear and sensible precedence.
You are mixing bit-ops and arithmetic unnecessarily, but you are
also too lazy to write parenthesis to clear up your dirty code?

 * Why do << >> have their own level anyway
As you have been told so many times; to not require parentheses
unnecessarily, to be able to omit them and not pollute the code
with parentheses in a language that is already full of all sorts
of { } [ ] ( ) and other punctuation characters.

 * Why do == != have a difference precendence from < <= >= >
I've explained that already twice in the past.

 Further, here: 'a * b + c' the multplication is done first, but here:
     a  *= b += c
 It is done second.
You understand that '=', '*=', and '*' are three different things,
don't you?
I hope you understand that '=' should have low precedence. And that
it makes sense to evaluate that from right to left. Do you follow?
"C" obviously decided to have them all, =, +=, *=, etc. in a single
group, and thus evaluated from right to left. - Easy rule, easy to
memorize. - And that is actually what you are demanding from many
other operators, to put them in a single group. - But here you are
complaining about it!
Of course the rules for those combined (sort of two-address) operators
could have been defined differently, in an own group with other rules.
(Algol 68 had done that, actually; the semantics are like "apply these
operations from left to right, indicating an incremental modification
of the underlying value.)
If "C" would have separated these operators from the assignment and
created another own group with different evaluation rules you'd also
have complained.

 The issue I have is whether augmented assignments should return a value at all. It's just generally too confusing especially with mixed types.
If you're confused about something either try to understand the rule,
or just learn it without understanding it, or look it up, a or write
your programs in a way that you understand; use parentheses, separate
complex expressions to simpler ones, etc.

It's confusing enough with assignments returning a value:
     a = b = x;
If it hurts/confuses you then don't use that feature.

 Here, assuming x has no side-effects, you might expect this to mean the same as:
     b = x;
    a = x;
I cannot tell what your brain makes you expect one semantic or another.
The semantics are clearly defined. Your interpretation here is wrong.
All I can suggest is what I've written above already; and to spare you
a search, it was:
If you're confused about something either try to understand the rule,
or just learn it without understanding it, or look it up, a or write
your programs in a way that you understand; use parentheses, separate
complex expressions to simpler ones, etc.

 In fact it's more like: 'b = x; a = b;'. Example:
      double a;
     float b;
      a  = b = 3.14159265358979323846;
 Here, 'a' will be assigned the less precise 32-bit version of the RHS.
And why are you composing such stupid examples (if not only for sake
of an argument)? - An experienced programmer wouldn't write such an
expression with mixed types if he intends clear and non-dubious code.
Janis

Date Sujet#  Auteur
27 May 26 * this girl calls c ugly365fir
27 May 26 `* Re: this girl calls c ugly364fir
28 May 26  `* Re: this girl calls c ugly363BGB
28 May 26   +* Re: this girl calls c ugly5Lawrence D’Oliveiro
28 May 26   i+* Re: this girl calls c ugly3BGB
29 May 26   ii`* Re: this girl calls c ugly2Lawrence D’Oliveiro
29 May 26   ii `- Re: this girl calls c ugly1BGB
28 May 26   i`- Re: this girl calls c ugly1Bonita Montero
28 May 26   +* Re: this girl calls c ugly19Janis Papanagnou
28 May 26   i+* Re: this girl calls c ugly15BGB
29 May 26   ii+- Re: this girl calls c ugly1Lawrence D’Oliveiro
29 May 26   ii`* Re: this girl calls c ugly13Janis Papanagnou
29 May 26   ii `* Re: this girl calls c ugly12BGB
29 May 26   ii  +* Re: this girl calls c ugly9David Brown
29 May 26   ii  i`* Re: this girl calls c ugly8BGB
30 May 26   ii  i `* Re: this girl calls c ugly7David Brown
30 May 26   ii  i  +* Re: this girl calls c ugly2Janis Papanagnou
30 May 26   ii  i  i`- Re: this girl calls c ugly1David Brown
30 May 26   ii  i  `* Re: this girl calls c ugly4BGB
31 May 26   ii  i   `* Re: this girl calls c ugly3David Brown
31 May 26   ii  i    `* Re: this girl calls c ugly2BGB
31 May 26   ii  i     `- Re: this girl calls c ugly1David Brown
29 May 26   ii  +- Re: this girl calls c ugly1Janis Papanagnou
30 May 26   ii  `- Re: this girl calls c ugly1Lawrence D’Oliveiro
28 May 26   i`* Re: this girl calls c ugly3Chris M. Thomasson
29 May 26   i `* Re: this girl calls c ugly2Janis Papanagnou
29 May 26   i  `- Re: this girl calls c ugly1Chris M. Thomasson
28 May 26   `* Re: this girl calls c ugly338fir
28 May 26    `* Re: this girl calls c ugly337BGB
29 May 26     +* Re: this girl calls c ugly330Lawrence D’Oliveiro
29 May 26     i`* Re: this girl calls c ugly329Janis Papanagnou
29 May 26     i `* Re: this girl calls c ugly328Bart
29 May 26     i  +* Re: this girl calls c ugly312Janis Papanagnou
29 May 26     i  i`* Re: this girl calls c ugly311Bart
29 May 26     i  i +* Re: this girl calls c ugly9Janis Papanagnou
29 May 26     i  i i+* Re: this girl calls c ugly2Bart
29 May 26     i  i ii`- Re: this girl calls c ugly1Janis Papanagnou
29 May 26     i  i i`* Re: this girl calls c ugly6Bart
29 May 26     i  i i +* Re: this girl calls c ugly4Janis Papanagnou
29 May 26     i  i i i`* Re: this girl calls c ugly3Bart
29 May 26     i  i i i `* Re: this girl calls c ugly2Janis Papanagnou
29 May 26     i  i i i  `- Re: this girl calls c ugly1Bart
29 May 26     i  i i `- Re: this girl calls c ugly1Keith Thompson
29 May 26     i  i `* Re: this girl calls c ugly301tTh
29 May 26     i  i  `* Re: this girl calls c ugly300Bart
29 May 26     i  i   +* Re: this girl calls c ugly298Keith Thompson
29 May 26     i  i   i`* Re: this girl calls c ugly297Bart
29 May 26     i  i   i +- Re: this girl calls c ugly1Janis Papanagnou
29 May 26     i  i   i `* Re: this girl calls c ugly295Keith Thompson
29 May 26     i  i   i  `* Re: this girl calls c ugly294Bart
29 May 26     i  i   i   +* Re: this girl calls c ugly5Keith Thompson
30 May 26     i  i   i   i`* Re: this girl calls c ugly4James Kuyper
30 May 26     i  i   i   i `* Re: this girl calls c ugly3Bart
30 May 26     i  i   i   i  `* Re: this girl calls c ugly2Keith Thompson
30 May 26     i  i   i   i   `- Re: this girl calls c ugly1Bart
30 May 26     i  i   i   `* Re: this girl calls c ugly288Dan Cross
30 May 26     i  i   i    +* Re: this girl calls c ugly284Bart
31 May 26     i  i   i    i+* Re: this girl calls c ugly282Keith Thompson
31 May 26     i  i   i    ii+* Re: this girl calls c ugly5Janis Papanagnou
31 May 26     i  i   i    iii+* Re: this girl calls c ugly2Keith Thompson
2 Jun 26     i  i   i    iiii`- Re: this girl calls c ugly1Janis Papanagnou
31 May 26     i  i   i    iii`* Re: this girl calls c ugly2David Brown
2 Jun 26     i  i   i    iii `- Re: this girl calls c ugly1Janis Papanagnou
31 May 26     i  i   i    ii`* Re: this girl calls c ugly276Richard Harnden
31 May 26     i  i   i    ii +* Re: this girl calls c ugly171David Brown
31 May 26     i  i   i    ii i+* Re: this girl calls c ugly168Bart
31 May 26     i  i   i    ii ii+* Re: this girl calls c ugly142David Brown
31 May 26     i  i   i    ii iii`* Re: this girl calls c ugly141James Kuyper
31 May 26     i  i   i    ii iii `* Re: this girl calls c ugly140David Brown
31 May 26     i  i   i    ii iii  +* Re: this girl calls c ugly4James Kuyper
31 May 26     i  i   i    ii iii  i`* Re: this girl calls c ugly3David Brown
31 May 26     i  i   i    ii iii  i `* Re: this girl calls c ugly2James Kuyper
1 Jun 26     i  i   i    ii iii  i  `- Re: this girl calls c ugly1David Brown
31 May 26     i  i   i    ii iii  `* Re: this girl calls c ugly135Keith Thompson
1 Jun 26     i  i   i    ii iii   +* Re: this girl calls c ugly2David Brown
1 Jun 26     i  i   i    ii iii   i`- Re: this girl calls c ugly1Keith Thompson
2 Jun 26     i  i   i    ii iii   +* Re: this girl calls c ugly131Janis Papanagnou
2 Jun 26     i  i   i    ii iii   i+- Re: this girl calls c ugly1James Kuyper
2 Jun 26     i  i   i    ii iii   i+* Constants and undefined behavior84Tim Rentsch
2 Jun 26     i  i   i    ii iii   ii`* Re: Constants and undefined behavior83Dan Cross
4 Jun 26     i  i   i    ii iii   ii `* Re: Constants and undefined behavior82Tim Rentsch
4 Jun 26     i  i   i    ii iii   ii  `* Re: Constants and undefined behavior81Dan Cross
4 Jun 26     i  i   i    ii iii   ii   +* Re: Constants and undefined behavior31Keith Thompson
5 Jun 26     i  i   i    ii iii   ii   i+* Re: Constants and undefined behavior28Dan Cross
5 Jun 26     i  i   i    ii iii   ii   ii+* Re: Constants and undefined behavior24Keith Thompson
6 Jun 26     i  i   i    ii iii   ii   iii+* Re: Constants and undefined behavior19Dan Cross
6 Jun 26     i  i   i    ii iii   ii   iiii`* Re: Constants and undefined behavior18Keith Thompson
8 Jun 26     i  i   i    ii iii   ii   iiii `* Re: Constants and undefined behavior17Dan Cross
8 Jun 26     i  i   i    ii iii   ii   iiii  +* Re: Constants and undefined behavior5Keith Thompson
9 Jun 26     i  i   i    ii iii   ii   iiii  i`* Re: Constants and undefined behavior4Dan Cross
9 Jun 26     i  i   i    ii iii   ii   iiii  i `* Re: Constants and undefined behavior3Keith Thompson
9 Jun 26     i  i   i    ii iii   ii   iiii  i  `* Re: Constants and undefined behavior2Dan Cross
9 Jun 26     i  i   i    ii iii   ii   iiii  i   `- Re: Constants and undefined behavior1Keith Thompson
9 Jun 26     i  i   i    ii iii   ii   iiii  `* Re: Constants and undefined behavior11Waldek Hebisch
9 Jun 26     i  i   i    ii iii   ii   iiii   +* Re: Constants and undefined behavior3James Kuyper
10 Jun 26     i  i   i    ii iii   ii   iiii   i`* Re: Constants and undefined behavior2Keith Thompson
10 Jun 26     i  i   i    ii iii   ii   iiii   i `- Re: Constants and undefined behavior1Dan Cross
11 Jun 26     i  i   i    ii iii   ii   iiii   `* Re: Constants and undefined behavior7Janis Papanagnou
11 Jun 26     i  i   i    ii iii   ii   iiii    +* Re: Constants and undefined behavior2Dan Cross
11 Jun 26     i  i   i    ii iii   ii   iiii    i`- Re: Constants and undefined behavior1Janis Papanagnou
11 Jun 26     i  i   i    ii iii   ii   iiii    `* Re: Constants and undefined behavior4Waldek Hebisch
6 Jun 26     i  i   i    ii iii   ii   iii`* Re: Constants and undefined behavior4Tim Rentsch
5 Jun 26     i  i   i    ii iii   ii   ii`* Re: Constants and undefined behavior3Janis Papanagnou
7 Jun 26     i  i   i    ii iii   ii   i`* Re: Constants and undefined behavior2Tim Rentsch
9 Jun 26     i  i   i    ii iii   ii   `* Re: Constants and undefined behavior49Tim Rentsch
2 Jun 26     i  i   i    ii iii   i`* Re: this girl calls c ugly45Keith Thompson
2 Jun 26     i  i   i    ii iii   `- Re: this girl calls c ugly1Chris M. Thomasson
2 Jun 26     i  i   i    ii ii`* Re: this girl calls c ugly25Dan Cross
31 May 26     i  i   i    ii i`* Re: this girl calls c ugly2James Kuyper
31 May 26     i  i   i    ii +* Re: this girl calls c ugly2Keith Thompson
31 May 26     i  i   i    ii `* Re: this girl calls c ugly102Tim Rentsch
31 May 26     i  i   i    i`- Re: this girl calls c ugly1Dan Cross
1 Jun 26     i  i   i    `* Re: this girl calls c ugly3Tim Rentsch
30 May 26     i  i   `- Re: this girl calls c ugly1David Brown
29 May 26     i  +* Re: this girl calls c ugly6Janis Papanagnou
30 May 26     i  `* Re: this girl calls c ugly9Lawrence D’Oliveiro
29 May 26     `* Re: this girl calls c ugly6Bonita Montero

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal