sandeep <> writes:
> Keith Thompson writes:
>> sandeep <> writes:
[...]
>> C++ is not strictly upward compatible with C anyway; this reuse of an
>> obscure keyword doesn't make the situation significantly worse.
>
> In my opinion, compatibility with C++ is one of C's greatest assets. I
> recommend the ISO C body to move towards these two goals viz-a-viz C++:
I'd say that compatibility with C is an asset of C++ (the reverse
of what you wrote). Whether it's one of its *greatest* assets is
an open question.
> 1. any program that is syntactically valid both in C and C++, should have
> the same semantics in both languages
That's mostly true now, and the exceptions are unlikely to go away.
For example, there are good reasons for character constants to be
of type int in C and of type char in C++.
> 2. as much syntactically valid C++ as possible, should also be valid C
The only way to fully achieve that goal would be to make C a clone
of C++. C will always be (nearly) a subset of C++; that's what
the "++" means. Moving C closer to C++ just for the sake of doing
so is not particularly useful. If C++ is what you want, you know
where to find it.
[...]
>>> ===
>>> A regular expression standard library component ===
>>>
>>> Recommendation: Many programs use regular expressions, so this would be
>>> a useful addition to C's standard library, again it should be done to
>>> maintain compatibility with C++.
>>
>> C/C++ compatibility generally means that C code is valid C++ code, not
>> the other way around. C++ has lots of stuff that C doesn't (classes,
>> exceptions, templates, etc.); this regular expression library would be
>> just one more such feature.
>>
>> It *might* be sufficiently useful to add to C, but C++ compatibility
>> isn't a strong reason to do so. And it might not be C-compatible
>> anyway, for example if it's defined in terms of C++ classes. (I haven't
>> looked at it.)
>
> Don't forget that C++ classes can be emulated in C using structs with a
> vtable of function-pointers for the methods.
And requiring that kind of machinery in a C standard regexp library
would be absurd.
http://www.open-std.org/JTC1/SC22/WG...2010/n3126.pdf is
the current draft of the upcoming C++ standard. Chapter 28 covers
the regular expression library. Take a look at it, and think about
implementing something equivalent in C. (For starters, there are
dozens of occurrences of the "template" keyword.)
[...]
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"