[Nickle]"purely" functional nickle (was: Recursive datatypes)
Keith Packard
nickle@nickle.org
Thu, 25 Jul 2002 08:30:06 -0700
Around 10 o'clock on Jul 25, Carl Worth wrote:
> > To avoid pure polymorphism, you can use a union type instead:
> >
> > if (l.ref == listend) printf ("yes\n");
>
> I suppose that was intended to be:
>
> if (l.ref == (listref.end) <>) printf ("yes\n");
I'd defined 'listend' as a variable holding that value so that the syntax
wasn't quite so horrible.
> I ended up just using poly. I made a global struct value named nil as
> a placeholder for list termination. When the new poly zero is in
> place, I can get rid of my nil.
You can use 0 now; all that the new poly zero is going to do is permit
some run-time typechecking of pointer types.
Using poly is certainly easier at the moment; the union syntax is just too
painful.
> That is, if f accepts M arguments and g accepts N arguments,
> then compose would return a function accepting N + (M-1) arguments
> that would return f(g(arg1, ..., argN), argN+1, ..., argN+M-1).
>
> I don't suppose there would be any way to write such a beast in
> nickle?
Nickle doesn't have the necessary reflective operators; you'd need some
way to talk about the number of arguments expected by each function. Given
that, we could easily add some syntax like:
int foo (int a, int b)
{
return a + b;
}
int bar (int args...)
{
foo (args...);
}
Now you could decompose the argument list into two arrays and call the
functions.
Keith Packard XFree86 Core Team HP Cambridge Research Lab