mutually-recursive types and an old puzzle
Gabriel Dos Reis
gdr@acm.org
Wed Jun 30 09:45:00 GMT 2004
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?
More information about the Gcc
mailing list