Liste des Groupes | Revenir à c arch |
On 05/09/2024 02:56, MitchAlsup1 wrote:The Ada language can work in both ways. If you just have:On Thu, 5 Sep 2024 0:41:36 +0000, BGB wrote:You snipped rather unfortunately here - it makes it look like this was code that Scott wrote, and you've removed essential context by BGB.
>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.
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.While Ada has low market penetration, I don't think it quite qualifies as a one-person language -- yet :-)
Les messages affichés proviennent d'usenet.