Re: Is necessary to switch to C++ or some object-oriented language?



On Mar 22, 5:02 pm, "user923005" <dcor...@xxxxxxxxx> wrote:
On Mar 22, 4:35 pm, "J. J. Farrell" <j...@xxxxxxxxxx> wrote:
On Mar 22, 11:48 am, "user923005" <dcor...@xxxxxxxxx> wrote:
On Mar 21, 7:16 pm, "J. J. Farrell" <j...@xxxxxxxxxx> wrote:
On Mar 21, 2:14 pm, "user923005" <dcor...@xxxxxxxxx> wrote:
On Mar 21, 1:38 pm, rpbg...@xxxxxxxxx (Roland Pibinger) wrote:
Syntactically, C is a subset of C++ with minor exceptions. This fact
was the main reason for C++'s initial success.

Even Bjarne Stroustrup has admitted that this claim is false.
C is not a subset of C++ with minor exceptions.

I suppose it hinges on what you consider "minor", but please specify
why you consider this claim to be false. It's very rare for programs
to need to call main() recursively, or to care about the type of a
charater constant, for example. The need to cast void * to other
object pointer types is slightly more intrusive, but I'd still
consider it minor. Which are the non-minor exceptions?

Take this tarball:http://wwwmaster.postgresql.org/download/mirrors-ftp?file=%2Fsource%2...
Which is the PostgreSQL database (written in the C language).
Rename all of the .c files to .cpp and try to compile it.
Basically none of the files will compile.

I don't see how that's relevant to the question. If the minor
exceptions are widely used, there'll obviously be problems compiling

Many of the problems are related to keywords.
Some of the problems are caused by the new casting rules (the C style
casts are no longer acceptable in certain cases).
There are various other differences pointed out in the document
appearing elsethread from AT&T.

Whatever the reasons are, the code bases have diverged. To me,
language differences are not minor if code cannot even be compiled
without rewriting it.

The changes from C to C++ are more drastic than from Fortran IV to
Fortran95.

I suppose that each and every difference between C and C++ could be
considered minor differences. But if those differences mean that a
major rewrite is necessary to compile, then *I* consider them to be
major differences. I guess by major I was thinking in terms of things
like "It would cost over one million dollars to convert PostgreSQL
from C into C++"

It is true that there is a subset of C that will compile and run as
C++. But programs in real life are almost never members of that set.

Agreed on all counts - different interpretations of "minor". The list
of differences is small, and each of them is minor. It is possible to
turn valid C code into valid C++ code with a few minor modifications;
that is, it is incredibly unlikely to need any redesign, almost all
the changes would be little more than editorial, and there usually
wouldn't be that many of them. That doesn't mean that C code can be
compiled as C++ code, or that it's a minor job to take a real-world C
program and do the minimal work required to make it a valid C++
program.



.



Relevant Pages

  • Re: The origins of CL conditions system
    ... that it may be good to let the user steer the behavior of the program. ... C++ exceptions took, to try and reconstruct what might've been going ... making compiled code and interpreted code work way ... trying to lexically compile your web server and client together so you ...
    (comp.lang.lisp)
  • Re: Is necessary to switch to C++ or some object-oriented language?
    ... was the main reason for C++'s initial success. ... C is not a subset of C++ with minor exceptions. ... Rename all of the .c files to .cpp and try to compile it. ... The changes from C to C++ are more drastic than from Fortran IV to ...
    (comp.lang.c)
  • Re: Is necessary to switch to C++ or some object-oriented language?
    ... It's very rare for programs ... to need to call mainrecursively, or to care about the type of a ... Rename all of the .c files to .cpp and try to compile it. ... exceptions are widely used, ...
    (comp.lang.c)
  • Re: Destroy the parent of the control
    ... all exceptions to break into the VC debugger, ... VB IDE and compile. ... Microsoft MVP, MCSD ...
    (microsoft.public.vc.atl)
  • Re: disabling RTTI
    ... > What could be the reason? ... One way to implement exceptions is to use the type_info ... records that the RTTI infrastructure requires. ...
    (comp.lang.cpp)