K
Kenneth Brody
jacob said:Richard Heathfield a écrit : [... C99 ...]// comments? More sugar. VLAs? More sugar.Mixed declarations? Sugar.
And what do you have against sugar?
You drink your coffee without it?
Many people don't like sugar in their coffee.
I mean, C is just syntatic sugar for assembly language. Why
not program in assembly then?
Portability.
[...]
VLAs are a more substantial step since it allows to allocate precisely
the memory the program needs without having to over-allocate or risk
under allocating arrays.
Under C89 you have to either:
1) allocate memory with malloc
2) Decide a maximum size and declare a local array of that size.
Both solutions aren't specially good. The first one implies using malloc
with all associated hassle,
What "hassle"?
Oh, no! I have to remember to free it! However shall I handle the
pressure?
and the second risks allocating not enough
memory. C99 allows you to precisely allocate what you need and no more.
Yet, as I understand it, if the VLA can't be allocated, the result
is undefined behavior. With malloc/free, you have well-defined
behavior for failure. True, you have to check for failure, but at
least you _can_ check for failure, unlike VLAs.
[...]
That is a progress too, but (I do not know why) we never discuss them
in this group.
Because they're not part of C itself.
Maybe what frustrates me is that all this talk about "Stay in C89, C99
is not portable" is that it has taken me years of effort to implement
(and not all of it) C99 and that not even in this group, where we should
promote standard C C99 is accepted as what it is, the current standard.
C99 is portable to systems which have C99 compilers.
AFAIK, C99 questions are not off-topic here, even if people will
point out that it's C99. (Of course, I may be wrong.)
I mean, each one of us has a picture of what C "should be". But if we
are going to get into *some* kind of consensus it must be the published
standard of the language, whether we like it or not.
Umm... Isn't that what we do here?
For instance the fact that main() returns zero even if the programmer
doesn't specify it I find that an abomination. But I implemented that
because it is the standard even if I do not like it at all.
That was probably a concession to not break formerly "working"
programs which weren't really "right" to begin with.
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:[email protected]>