Sujet : Re: Computer architects leaving Intel...
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.archDate : 05. Sep 2024, 08:54:56
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vbbo4g$8j04$2@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 05/09/2024 02:56, MitchAlsup1 wrote:
On Thu, 5 Sep 2024 0:41:36 +0000, BGB wrote:
On 9/4/2024 3:59 PM, Scott Lurndal wrote:
>
Say:
long z;
int x, y;
...
z=x*y;
Would auto-promote to long before the multiply.
\I may have to use this as an example of C allowing the programmer
to shoot himself in the foot; promotion or no promotion.
You snipped rather unfortunately here - it makes it look like this was code that Scott wrote, and you've removed essential context by BGB.
While I agree it is an example of the kind of code that people sometimes write when they don't understand C arithmetic, I don't think it is C-specific. I can't think of any language off-hand where expressions are evaluated differently depending on types used further out in the expression. Can you give any examples of languages where the equivalent code would either do the multiplication as "long", or give an error so that the programmer would be informed of their error?
(I don't count personal one-person languages here. They are very rarely formally or accurately specified.)