There's two issues with purity (similar to generators):
Is 
        fold_left 

pure? I think it is. However, if it is passed an impure argument function ..
the result isn't.This applies to totality as well. Fold_left is total in itself.
But the application 

        fold_left f init

is only total if 'f' is total over its arguments. This is all similar to the 
problem with
exception specification in C++. Related case:

        fun strng[T with Str[T]] (x:t) => str x;

strng is total/pure iff str is. Of course we can make virtual functions
pure, which is then a constraint on implementation, but it doesn't solve
the problem, similar to "const crap": we'd new two functions:

        fold_left_pure // requires pure argument
        fold_left_impure // allows impure argument

OR we have to 

(a) provide subtyping so D - pure -> C is a subtype 
of D -> C (maybe impure)

(b) also provide variance notation or something which allows
to transmit the purity (or totality) of the argument to a HOF.

This is similar to const problem with C++ iterators:
you get a combinatorial explosion created by levels of indirection.
In C++, no way to propagate the const (well, maybe decl_type will
allow people to try, but it is unlikely to work properly because 
decl_type is a hack).

This all suggests the usual Felix cheating: let the annotations 
work on direct calls but don't propagate. Currently that
means "fold_left" could be passed a generator, since generators
have the same type as functions. In turn that means all closures
have to be treated as generators (since we can't tell if they're
generators or functions from the type, which is the only information
available).

--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to