Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #154483

Re: Two different Results between C and C++

From Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups comp.lang.c
Subject Re: Two different Results between C and C++
Date 2020-09-04 05:21 -0700
Organization A noiseless patient Spider
Message-ID <86o8ml7mxa.fsf@linuxsc.com> (permalink)
References (2 earlier) <rb5v6i$pv5$1@dont-email.me> <60d0f73c-8588-4673-a48d-e5c4cc726196@googlegroups.com> <87blm1wam0.fsf@nosuchdomain.example.com> <86d05skg6z.fsf@linuxsc.com> <38c7640f-c674-4952-9af5-ce68f66b245co@googlegroups.com>

Show all headers | View raw


James Kuyper <jameskuyper@alumni.caltech.edu> writes:

> On Sunday, June 21, 2020 at 3:53:49 AM UTC-4, Tim Rentsch wrote:
>
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>
>>> John Bode <jfbode1029@gmail.com> writes:
>
> ...
>
>>>> There are an infinite number of programs that are legal C but not
>>>> legal C++.  There are an infinite number of programs that are legal
>>>> in both languages but exhibit different behavior.
>>>
>>> There are also an infinite number of programs that are legal C and
>>> legal C++ with the same behavior.
>>>
>>> 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.
>
> It neither an article of faith,

You cannot know that, since you don't know what Keith is
thinking.

> nor an empirical statement.  It's a conclusion easily reached by
> anyone who knows both languages well enough to be aware of what
> needs to be done to make the conversion.

I still don't see any evidence being offered to support that
assertion.

> Knowing enough to reach
> that conclusion is made easier by the fact that Annex C of the C++
> standard provides what's supposed to be a comprehensive list of the
> relevant issues.

If you think that list is even close to being complete then you
really haven't been paying attention.

> If you don't think that it is comprehensive, it
> would be helpful to identify what's missing, incomplete, or
> incorrect in Annex C.

Have you even tried looking for other cases?  Whether you have or
not, it's not my problem.  The world does not revolve around you.

>> So if we are going to make a statement about "almost all" C
>> programs, almost all C programs take more than a small effort to be
>> transformed into well-formed and equivalent C++, for any value of
>> "small effort" one might choose.
>
> Here's where we move from theory into empirical arguments.  As a
> practical matter, I've done the relevant conversions many times, and
> it's trivial in most cases.

Considering what you said above, whether you have done so even
once is subject to doubt.  If you don't know whether the end
result has the same semantics in C++ as in C, then you don't
know if the conversion has been accomplished.

> Your belief that it's usually quite
> difficult is something that I find quite mystifying.

It's not a statement of belief, it's a deduction.  The deduction
is based on an understanding of the structure of language and
an understanding of the necessary mathematics (which actually
isn't all that much, but it is greater than zero).  Did you make
any effort at all to follow the sketch I gave of the reasoning
underlying the deduction?  If you did then was there something
about it that you didn't understand?  Or, if you didn't, then
it isn't really surprising that you would be mystified by
an explanation you chose to ignore.

Back to comp.lang.c | Previous | NextNext in thread | Find similar


Thread

Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-04 05:21 -0700
  Re: Two different Results between C and C++ "james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> - 2020-09-05 13:02 -0700
    Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-10 06:36 -0700
      Re: Two different Results between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-09-10 12:03 -0700
        Re: Two different Results between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-09-12 21:55 -0700

csiph-web