On 13/01/17 19:02, Rick C. Hodgin wrote:
> On Friday, January 13, 2017 at 12:47:52 PM UTC-5, David Brown wrote:
>> On 13/01/17 18:20, Rick C. Hodgin wrote:
>>> On Friday, January 13, 2017 at 6:50:00 AM UTC-5, David Brown wrote:
>>>> And what "syntax relaxations" are you talking about?
>>>
>>> (1) Not using struct keyword everywhere, coupled to
>>
>> You don't have to use "struct" keyword everywhere. When I program in C,
>> I rarely need it any more than in C++ - because I like to typedef my
>> structs. So this is a non-issue.
>
> You do unless you use a typdef.
>
>>> (2) Not having to use typedef.
>>
>> Having to write "typedef" when defining structs and enum types is such a
>> negligible issue that this is also a non-issue.
>
> We differ in opinions here.
Apparently so.
Nonetheless, you certainly don't get to count (1) and (2) as two
different issues - it is a single combined point that I believe most
people would consider minor.
>
>>> (3) Native bool type.
>>
>> C has _Bool, and after #include <stdbool.h> you have bool, true, false
>> just like in C++. So this is also a non-issue.
>
> _Bool is not bool. It's close, but it doesn't have to be one byte.
> And, it's not included with Visual Studio.
_Bool in C works like bool in C++. In neither case do they have to be
single byte (not that the size of "byte" is fixed in C). In practice,
both /are/ a single byte. I certainly know of no C/C++ compiler that
implements C _Bool in any other way than C++ bool.
The failings of MSVC to implement 20 year old C standards is not a
failing of C. It /is/ a reason to use MSVC C++ mode rather than MSVC C
mode to compile your C code - if you are stuck with only a very limited
C compiler. But you should be clear that C /has/ a native Boolean type
that is exactly like that of C++, even if you are unable to use it with
your choice of C compiler.
>
>>> (4) Use of & types (int&, char&).
>>> (5) Function overloading.
>>> (6) Parameter initialization on definition line.
>>
>> What, like "int x = foo();" rather than "int x; x = foo();" or defining
>> your variables at the start of a function? (I'm thinking local
>> variables here.) C has supported that for so long that I don't know
>> when it was introduced. Freely mixing declarations and statements is
>> from C99. (The lack of such mixing is one of my key dislikes about C90.)
>
> This:
>
> int myfunc(int a, int b = 3, char* c = NULL);
>
> With usage:
>
> myfunc(5);
>
> It automatically populates b and c for you.
This is a different thing - it is default parameters. And that goes
along with most of your points as a useful feature of C++ - but nothing
to do with using a C++ compiler to compile C code.
>
>> Basically, what you are saying is that you like some C++ features and
>> like to use them in your coding, even though you also /dislike/ certain
>> other C++ features and you avoid them.
>
> I think C should have these features, as they are very C-like, and
> are not really C++-like. C++-like features are in the class and its
> many features.
I don't disagree that they might be /useful/ in C, and that these
features are all nice points in C++. Whether they are "C-like" is much
less clear, as is the question of whether C would be a "better" language
if they were included. I suspect that if they were considered
sufficiently C-like, and sufficiently useful in C style programming,
then compilers such as gcc would allow at least some of them as
extensions. (It already allows a little flexibility of some features
between C and C++ and between different standards of C and C++.)
The fact that these features are considered integral parts of C++, but
are not part of C at all, suggests that by definition they are C++-like
and not C-like.
>
>> That's fine - but you are programming in C++ with limitations. You are
>> not using a C++ compiler to compile your C code.
>
> 99% of what I write is C code. The 1% that's not is as I indicate
> above. And, as I have stated repeatedly, even asking for some of
> these features to be considered for inclusion on comp.std.c, I
> believe these should be C features.
>
>> And that applies even if you think that some or all of these features
>> should be part of C.
>
> I am not confined in my thinking of what C should be based on what
> the C standard says. I look at C as a type of thing, rather than
> the explicitly defined thing. I look at the C Standard as a thing,
> and C itself to be more of a philosophy.
>
C /is/ defined by the standards. That is what C is.
I believe I understand what you are trying to say here, I just don't
think you are using the right words to describe the way you like to
program. Structured procedural programming, perhaps? I am not sure.
> I intend to introduce these features into CAlive, and be done with
> it. And my offering here to Fernando D. Bozzo is an offering to
> simplify his programming life in C by using these few features of
> a C++ compiler, and by switching to a C++ compiler to use them.
For the umpteenth time, it is not an "offering" - this is not a temple.
You are giving advice or suggestions, like everyone else.
If he is interested in C programming, your advice is bad - you are
suggesting he breaks from the language that all other C programmers use.
If he is interested in C++ programming, your advice is bad - you are
suggesting he hobbles his programming and misses most of the point of
the language. /You/ can choose to program in a language that is mostly
C but with some C++ bits thrown in - but it is not something that should
be recommended to someone starting out in C programming.