This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: mutually-recursive types and an old puzzle
- From: "Gabriel Dos Reis" <gdr at acm dot org>
- To: "Chris Lattner" <sabre at nondot dot org>
- Cc: "Gabriel Dos Reis" <gdr at acm dot org>,"Joe Buck" <joe dot buck at synopsys dot com>, gcc at gcc dot gnu dot org
- Date: Wed, 30 Jun 2004 11:10:10 +0200 (CEST)
- Subject: Re: mutually-recursive types and an old puzzle
- References: <32929.::ffff:128.194.146.36.1088557164.squirrel@webmail.nerim.net> <Pine.LNX.4.44.0406292255430.4981-100000@nondot.org>
- Reply-to: gdr at acm dot org
You Wrote Chris Lattner
> On Wed, 30 Jun 2004, Gabriel Dos Reis wrote:
>
>> Joe Buck:
>> > On Wed, Jun 30, 2004 at 02:43:06AM +0200, Gabriel Dos Reis wrote:
>> >> Yes, C does not has a fixpoint combinator. C++ does.
>> >>
>> >> struct T {
>> >> T operator()() const { return T(); }
>> >> };
>> >
>> > That doesn't quite suffice, but it looks like it can be made to do so
>> (we
>> > need a set of function-objects that can return references to each
>> other).
>>
>> I just gave a hint to why the fixpoint operator of C++ may suffice
>> to solve the puzzle -- it wasn't an final solution.
>> But, yes, either a set of function-objects that return
>> references to each other or a single class-type that encodes
>> the siwtching state can be made to give the solution. I guess
>> my most important claim is that a solution is possible within
>> C++ without reinterpret_cast (ro similar thing).
>
> Actually I thought the question was more about the IR level type-system
> than the source-level type-system. If you expand the C++ example above
> into an IR, you get structures, which even the C type-system can support
> (you can return a structure containing a function pointer that returns a
> structure).
Are we talking about the puzzle formulated by Joe?