On 27/06/2009, at 10:18 AM, Erick Tryzelaar wrote:

> I'm not sure if I completely understand you. As far as I can tell,
> this is a technique to turn folds into cursors, which you could use to
> write your polyadic functions.

I make two points: in C++, iterators + template hackery provides
a weak (not type checked) form of polyadic programming.

> For instance, we could take a cursor
> and write:
>
> let count c =
>  let aux init c =
>    match Lazy.force c with
>    | None -> init
>    | Some i, c -> aux (init + i) c
>  in
>  aux 0 c
>
> And it should work with all cursors.

Sure, but that's the point: cursors are polyadic if you can
hide the container type in the function.


> I interpreted it as as long as
> you can create continuations, you can convert folds into cursors.

And if you don't have them, you can do almost as well.

> I don't think Oleg is saying that folds are always better, but that by
> default ASTs should provide enumerators and convert them into cursors
> when they're needed.

He's saying enumerators are better because they provide certain  
guarantees
that cursors don't. And I'm saying this is a false economy because  
managing
the state variable in a fold to do the right thing is hard work, and  
re-introduces
all the same problems anyhow.

It is interesting there is a mechanical way to control invert to  
obtain cursors
from enumerators, in a sufficiently powerful language.

In Felix, fthreads do this (but only for procedures). First class  
continuations
are a low level way to do "stack swapping".

It's a pity Felix doesn't have first class functional continuations,  
but this
is a consequence of using the C object model (i.e. Felix functions use
the machine stack like C ones, allowing them to be freely mixed).

--
john skaller
skal...@users.sourceforge.net





------------------------------------------------------------------------------
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to