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


Groups > comp.lang.c > #112741

Re: Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss )

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss )
Date 2017-06-20 22:56 +0100
Organization A noiseless patient Spider
Message-ID <87tw3a9vc6.fsf@bsb.me.uk> (permalink)
References <e2fa453b-5161-4cd1-a96a-2246eba1e4fc@googlegroups.com> <f43b07dc-5164-45a8-87c5-074f098adabb@googlegroups.com> <87zid2a32f.fsf@bsb.me.uk> <ee7dd859-978b-4724-8bba-c4aa267815c2@googlegroups.com>

Show all headers | View raw


Thiago Adams <thiago.adams@gmail.com> writes:

> On Tuesday, June 20, 2017 at 4:09:52 PM UTC-3, Ben Bacarisse wrote:
>> Thiago Adams writes:
>> 
>> > On Tuesday, June 20, 2017 at 3:02:51 PM UTC-3, Thiago Adams wrote:
>> >
>> > [...]
>> >
>> >> '^' works like a pointer:
>> >> But, when generating destroy tells the generator that 
>> >> Y_Delete(p->pY) must be called.
>> >> 
>> >
>> > [...]
>> >
>> >> 
>> >> int main()
>> >> {
>> >>   Person ^ person = {};
>> >> } //ok delete person called (if null no effect)
>> >
>> >
>> >
>> > To create something like C++ smart pointers.
>> >
>> > typedef struct 
>> > {
>> >   int counter = 1;
>> > } RefCounted;
>> >
>> >
>> > void operator delete (RefCounted* p)
>> > {
>> >   if (p)
>> >   {
>> >     p->counter--;
>> >     if (p->counter == 0)
>> >     {
>> >      destroy p;
>> >     }
>> >   }
>> > }
>> 
>> I don't see how this is like C++'s special pointer templates.  They are
>> parameterised types and these have no type parameter.
>
> Sample:
<snip>
> In "C extended"
>
> int main()
> {
>   Person^ person = new Person;
> }
>
> No need for template type.

I don't see the connection with what I commented on, but I'm not sure
there is much pint in my trying to understand.  In future I'll I assume
that it will all work.

<snip>
-- 
Ben.

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


Thread

Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss ) Thiago Adams <thiago.adams@gmail.com> - 2017-06-20 11:02 -0700
  Re: Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss ) Thiago Adams <thiago.adams@gmail.com> - 2017-06-20 11:13 -0700
    Re: Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss ) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-20 20:09 +0100
      Re: Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss ) Thiago Adams <thiago.adams@gmail.com> - 2017-06-20 13:08 -0700
        Re: Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss ) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-20 22:56 +0100
          Re: Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss ) Thiago Adams <thiago.adams@gmail.com> - 2017-06-21 04:44 -0700
    Re: Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss ) scott@slp53.sl.home (Scott Lurndal) - 2017-06-20 20:20 +0000
      Re: Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss ) Thiago Adams <thiago.adams@gmail.com> - 2017-06-20 14:02 -0700
  Re: Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss ) GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-06-21 05:33 +0200
    Re: Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss ) Thiago Adams <thiago.adams@gmail.com> - 2017-06-21 04:29 -0700
  Re: Patterns for C code with code generation (new ,delete ,destroy , { }, dismiss ) Thiago Adams <thiago.adams@gmail.com> - 2017-07-08 11:15 -0700

csiph-web