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


Groups > comp.lang.c > #23640

Re: Map C++ feature to C

From Andrew Cooper <amc96@cam.ac.uk>
Newsgroups comp.lang.c
Subject Re: Map C++ feature to C
References <js6ip6$qb1$1@speranza.aioe.org> <a4o4ojFe9mU2@mid.individual.net> <js812m$ak3$1@speranza.aioe.org> <a4phm2FaukU1@mid.individual.net> <caf65604-f87f-4e89-a59e-56db88999717@googlegroups.com>
Message-ID <24mPr.29428$ja1.16975@fx33.am4> (permalink)
Organization virginmedia.com
Date 2012-07-24 01:34 +0100

Show all headers | View raw


On 23/07/2012 18:25, nroberts wrote:
> On Sunday, June 24, 2012 3:12:18 PM UTC-7, Ian Collins wrote:
>> On 06/25/12 09:33 AM, zgene wrote:
>> &gt; On Sun, 24 Jun 2012 21:25:38 +1200, Ian Collins wrote:
>> &gt;
>> &gt;&gt; On 06/24/12 08:23 PM, zgene wrote:
>> &gt;&gt;&gt; Dear friends
>> &gt;&gt;
>> &gt;&gt; Why is the question completely different form the subject?
>> &gt;&gt;
>> &gt;&gt;&gt; Is there a way to embulate C++&#39;s virtual destructors in pure C. IE just
>> &gt;&gt;&gt; using function pointers.
>> &gt;&gt;
>> &gt;&gt; No, because there isn&#39;t a way to fully emulate destructors.
>> &gt;
>> &gt; I doubt this answer..... do you have any evidence??
>>
>> Show me a way to automatically call a function on leaving a scope in C 
>> and we can go from there.
> 
> This is probably THE most important feature of C++ missing from standard C but it can be done with GCC extensions:
> 
> type var __attribute__(cleanup(destroyType)) = newType();
> 

It is not any feature "missing" from the C standard.  C is not C++, nor
should it be.  gcc extensions like this are frankly a bastardisation of
C, and should be discouraged.

C, unlike C++ has only one possible interpretation for any valid
construct.  This makes is substantially more predictable, and reduces
many overheads of the more complex features.

Take the following C++ code:

Foo f = Foo(g);

Care to explain exactly what that statement means?  What would be the
equivalent in meaning for C?

~Andrew

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Map C++ feature to C zgene <nospam@nospam.com> - 2012-06-24 08:23 +0000
  Re: Map C++ feature to C Ian Collins <ian-news@hotmail.com> - 2012-06-24 21:25 +1200
    Re: Map C++ feature to C BGB <cr88192@hotmail.com> - 2012-06-24 13:39 -0500
      Re: Map C++ feature to C Ian Collins <ian-news@hotmail.com> - 2012-06-25 10:15 +1200
        Re: Map C++ feature to C BGB <cr88192@hotmail.com> - 2012-06-25 11:32 -0500
    Re: Map C++ feature to C zgene <nospam@nospam.com> - 2012-06-24 21:33 +0000
      Re: Map C++ feature to C Ian Collins <ian-news@hotmail.com> - 2012-06-25 10:12 +1200
        Re: Map C++ feature to C William Ahern <william@wilbur.25thandClement.com> - 2012-06-24 18:49 -0700
        Re: Map C++ feature to C nroberts <roberts.noah@gmail.com> - 2012-07-23 10:25 -0700
          Re: Map C++ feature to C Andrew Cooper <amc96@cam.ac.uk> - 2012-07-24 01:34 +0100
            Re: Map C++ feature to C Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-07-24 15:58 +0000
  Re: Map C++ feature to C "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-06-24 11:36 -0700
    Re: Map C++ feature to C Leo Havmøller <rtxleh@nospam.nospam> - 2012-06-25 05:43 +0200
      Re: Map C++ feature to C Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-06-25 10:34 +0000
        Re: Map C++ feature to C BGB <cr88192@hotmail.com> - 2012-06-25 11:36 -0500
  Re: Map C++ feature to C Paul N <gw7rib@aol.com> - 2012-06-24 12:19 -0700
    Re: Map C++ feature to C 88888 Dihedral <dihedral88888@googlemail.com> - 2012-06-24 19:49 -0700
  Re: Map C++ feature to C aftnix <aftnix@gmail.com> - 2012-07-26 13:36 -0700

csiph-web