This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mutually-recursive types and an old puzzle


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).

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]