[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Aztec C: C ++??
On Apr 17, 11:15 am, pau...@saaf.se (Paul Schlyter) wrote:
> In ANSI C, struct's can be passed by value to functions and a function
> can have a struct as its return value. In K&R C you could only do that
> with pointers to struct's. And I think software like ANSI2KNR would
> have a quite hard time handling THAT case..... memory would have to
> be allocated for these struct parameters and automatically deallocated
> at the proper place.... I think you get the idea...
>
What a great discussion! Thanks Paul.
Great example of an intractable problem.
"As the size of the input to an algorithm increases, how do the
running time and memory requirements of the algorithm change and what
are the implications and ramifications of that change?"
This problem is easily solved by offsetting the stack pointer in a
function call by the size of the return value if we were writing a
compiler that is... but we are not and your point is a good one...
this is not translatable.
> In ANSI C, float arithmetic is allowed - in K&R C, real arithmetic always
> had to be performed as double arithmetic.
>
> A number of predefined macros was added to ANSI C.
>
> A number of new library functions was added to ANSI C. And in ANSI C,
> the standard library became part of the language - that was not the
> case with K&R C.
>
> In ANSI C, calling a pointer to a function could be performed with
> the regular function call syntax. One example:
>
> int (*fptr)(int,int);
>
> ......
>
> fptr = some_function;
>
> ......
>
> In ANSI C, this is legal while in K&R C it's a syntax error:
>
> fptr(23,45);
>
> In K&R C you *had* to call the function pointer like this:
>
> (*fptr)(23,45);
>
> That was legal too in ANSI C - even for a regular function! Thus, in
> ANSI C you can also do:
>
> (*printf)("Hello, world\n");
>
> would would be illegal in K&R C. In ANSI C you can even do:
>
> (*****************************************printf)("Hello, world\n");
>
> and it works !!!!
>
> In ANSI C you can do "string pasting", e.g.:
>
> char *s = "First part of string, " "second part of string";
>
> In K&R C you had to do it like this:
>
> char *s = "First part of string, second part of string";
>
> or like this:
>
> char *s = "First part of string, \
> second part of string";
>
> which looks a bit ugly....
>
> String pasting is particularly handy when you have strings defined
> as macros - you can then paste them together by just writing the
> macro names one after another.
>
> --
> ----------------------------------------------------------------
> Paul Schlyter, Grev Turegatan 40, SE-114 38 Stockholm, SWEDEN
> e-mail: pausch at stjarnhimlen dot se
> WWW: http://stjarnhimlen.se/
Yes, I understand. The translation program cannot work in some cases.
But on a side-note initialized string data can take-up too much space.
In the days before string resources, we would just link in a bunch of
initialized strings and point to them.