[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: the forward method [dynamic vs. static typing]
Ken Shan writes:
> On 2003-12-10T16:35:25-0500, FranklinChen@cmu.edu wrote:
> > > data SuperList a = SuperList a (SuperList [a])
> > I'm curious what you think about the following.
>
> I think the following, but C++ can't:
>
> template <class T>
> struct super_list
> {
> T t;
> super_list<vector<T> > children;
> };
You need a pointer:
template <class T>
struct super_list
{
T t;
super_list<vector<T> > *children;
};
works perfectly well. (Implementation of cool algorithms using
polymorphic recursion left to the reader.)
Or do you consider this not faithful to your intentions?
--
Franklin