[Coco] noob question

Mathieu Bouchard matju at artengine.ca
Thu Nov 9 13:41:36 EST 2017


Le 2017-11-08 à 14:35:00, Mark D. Overholser a écrit :
> On 08-Nov-17 03:41, Randy Weaver wrote:
> << BIG SNIP >>
>> I'm halfway through the K&R C book and am surprised how similar the 
> language is to C#.  Some things are handled differently but I understand 
> those differences.
>
> Since 'C' was released in the early 1970's and 'C#' was released in 
> 2000, you should note how Similar that 'C#' is to 'C'...  ;)

C of the early 1970's was more different. The introduction of proper function 
declarations and of modern function definitions in C++ in 1983 was later 
back-ported to C in ANSI C 1985, better known as ANSI C 1989 or ISO C 1990.

prior to C++ 1983, if you wanted to define this :
float pythagoras (float x, float y) {return sqrt(x*x+y*y);}

you had to declare it as :
float pythagoras (); /* no type-safety */

and then define it as (urgggghhh!!!) :
float pythagoras ()
   float x;
   float y;
{return sqrt(x*x+y*y);}

... which looks totally abnormal and confusing given today's languages :
semicolon within a definition but not within () nor {} !!!

and I don't even recall how it handled the difference between float and double 
back then (for example x+2.5 involves an implicit cast to double because the 
literal is a double, but what if the function receiving it wants a plain float 
?)

No wonder in older days, C had a bigger reputation of being an "assembly 
language with high-level syntax"...

  ______________________________________________________________________
| Mathieu BOUCHARD --- tél: 514.623.3801, 514.383.3801 --- Montréal, QC


More information about the Coco mailing list