Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #154515
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Two different Results between C and C++ |
| Date | 2020-09-04 11:46 -0700 |
| Organization | None to speak of |
| Message-ID | <87a6y5z8ge.fsf@nosuchdomain.example.com> (permalink) |
| References | (3 earlier) <60d0f73c-8588-4673-a48d-e5c4cc726196@googlegroups.com> <87blm1wam0.fsf@nosuchdomain.example.com> <86d05skg6z.fsf@linuxsc.com> <87tuz4gt4c.fsf@nosuchdomain.example.com> <86sgbx7sui.fsf@linuxsc.com> |
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> [...]
>>
>>>> All these statements are true, but none are particularly relevant.
>>>> You can construct an infinite number of valid C or C++ programs by
>>>> playing games with the grammar. There are an infinite number of
>>>> legal C programs that use conditional operators nested 10,000 levels
>>>> deep, but I doubt that any such programs exist in the wild (except
>>>> *maybe* as compiler capacity tests). I think it's more useful to
>>>> look at actual code rather than contrived infinite sets of programs.
>>>>
>>>> There are *some* programs that are legal C but not legal C++. The
>>>> most common causes of this are probably C++'s tighter restrictions on
>>>> implicit conversions involving void*, C code that uses C++ keywords
>>>> as identifiers, and C features that haven't been incorporated into
>>>> C++, such as VLAs, _Generic, and compound literals. But almost all
>>>> programs that are legal C but not legal C++ can be made into legal
>>>> C++ with a small effort.
>>>
>>> This claim sounds like an article of faith, being offered without
>>> either proof or evidence. If meant as just an empirical statement
>>> then of course there is no way anyone can know that.
>>
>> When I wrote "almost all programs that are legal C but not legal
>> C++", I was referring to real-world programs, not the infinite set
>> of all possible programs. I probably could have made that clearer.
>
> So you meant to consider only those C programs that have actually
> been written, rather than making a statement that would apply to
> any well-formed C program? So the statement was meant in the
> sense of "almost all existing programs" that are well-formed C?
>
>> My statement was not an "article of faith". It was somewhat
>> speculative.
>
> I am not offering any judgment on whether your statement actually
> is an article of faith for you; nor would I, since I cannot know
> what you are thinking. However, since you did not offer, and still
> have not offered, any sort of evidence or reasoning that supports
> the assertion, it does come across that way. You saying that the
> statement was somewhat speculative, without saying anything more
> specific, doesn't lessen that impression.
>
> Incidentally, I don't know why you put the phrase article of faith
> in scare quotes. It's an established phrase in regular English,
> dating back at least 500 years. A typical definition is "a
> deeply held belief".
Those were not scare quotes. You introduced the phrase "article of
faith" into this discussion. I was directly quoting you.
>> I think it was correct, but it's not worth the effort to
>> perform a major research project to verify it.
>
> Let's think about what you're saying. How many C programs have
> actually been written? A hundred thousand? A million? Of those,
> how many have you actually looked at? Probably a few hundred, but
> let's guess a thousand. Of the C programs you've seen, how many
> have you actually tried to convert to C++? Five? Ten? Twenty?
> Assuming the number is 20 and that 200,000 C programs have been
> written, that is 0.01%. Furthermore getting a C program to the
> point where it will compile as C++ is not the same as it being the
> same program. Even if we know the semantics of the C program was
> not changed by modifying it, there remains the question of whether
> the program has the same semantics in C++. Do you think you know
> all the ways that well-formed C code can have different semantics
> when compiled as C++? If you don't, then we shouldn't have much
> confidence in your estimate of the effort required to accomplish
> the modification, since we don't know whether the goal was actually
> reached. Is this what you mean when you say your claim is somewhat
> speculative? If it is then the word "somewhat" seems vastly
> understated.
Not every idle statement requires a research program to verify it.
Given my experience with C and C++, my *general impression* is that
most C programs can be made into valid C++ programs with the same
semantics without great effort by someone knowledgeable in both
languages. I speculate that the level of effort would be similar
to that for porting a program from one version of C to a later one,
or from one version of C++ to a later one.
I don't know off the top of my head all the ways that valid C
code can be valid C++ code with different semantics, but I believe
there's an annex in the C++ standard that provides that information.
I didn't expect that statement to be controversial, and I *DO NOT
CARE* enough about this to spend the time it would take to establish
it more firmly.
I note that you haven't said you disagree with my statement; rather
you seem to be criticizing the way I said it. I can't even tell
whether you agree or not. If you disagreed, I would ask you to
offer evidence.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-04 03:13 -0700
Re: Two different Results between C and C++ Kaz Kylheku <793-849-0957@kylheku.com> - 2020-09-04 18:44 +0000
Re: Two different Results between C and C++ David Brown <david.brown@hesbynett.no> - 2020-09-05 15:57 +0200
Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-08 08:27 -0700
Re: Two different Results between C and C++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-08 17:50 -0700
Re: Two different Results between C and C++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-08 21:07 -0400
Re: Two different Results between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-09-08 18:28 -0700
Re: Two different Results between C and C++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-08 22:14 -0400
Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-10 06:35 -0700
Re: Two different Results between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-09-04 11:46 -0700
Re: Two different Results between C and C++ Kaz Kylheku <793-849-0957@kylheku.com> - 2020-09-04 19:07 +0000
Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-10 04:15 -0700
Re: Two different Results between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-09-10 12:46 -0700
csiph-web