:: Re: [DNG] Why C/C++ ?
Top Page
Delete this message
Reply to this message
Author: Dan Purgert
Date:  
To: dng
Subject: Re: [DNG] Why C/C++ ?
On Aug 11, 2024, Didier Kryn wrote:
> Le 11/08/2024 à 04:06, Steve Litt a écrit :
> > I think it's a pretty darn good language. It makes sense, its syntax is
> > pretty guessable (except for pointers to functions), and it's a small
> > language that's easily learned.
> >
>     Yes, you think you learned it... but sometime you discover you missed
> something. And there's a lot one can miss in C. There's a lot of subtelties,
> like in automatic type promotion, for example, like the difference between
> static and automatic variables, static constants and automatic constants,
> embedded functions... And this horrible thing of using the equal sign for
> assignment:
>
> When you write
>
> x = 1;
>
> ...
>
> x = 2;
>
>     Any one having a notion of mathematics will call you a liar. And it
> forces you to use == to mean equality, which has been the source of zillions
> of bugs, because, in C, an assignment is an expression.


Why? You're reassigning the variable 'x' to the value 2 ...


>
>     In any human language, people count things by giving number 1 to the
> first and number n to the nth. In C the first has number 0 and the nth has
> number n-1. Just for the sake of pointer arithmetics.


... and the languages that start at 1 provide nothing but off-by-one
errors :P

>
>     The enumerations share one single namespace, which is the same as the
> variable names.
>
>     In C, INT_MAX+1 == -1   ( INT_MAX is defined in <limits.h>)


Shouldn't that be "INT_MIN", when you overflow a signed integer?

signed 8 bit INT_MAX is 0b01111111 (127)
             INT_MAX+1 = 0b10000000 (-128) 


Should hold true for 16,32,64-bit (signed) integers ... or am I having
problems doing math this morning? :)


--
|_|O|_|
|_|_|O| Github: https://github.com/dpurgert
|O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1 E067 6D65 70E5 4CE7 2860