On 01/07/2013, at 10:01 PM, srean wrote: > I see and it makes sense. I dont know how hard it would be, but a separate > type for functions that touch val or vars outside of its scope might be > useful.
Before you think about such a fine distinction, think about a coarser one: generators, which not only depend on vars .. they can modify them (have side effects). A distinct type can certainly be introduced. But consider: map: (int->int) -> list[int] -> list[int] We're using int->int as a function. So for a generator what do you do? Do you do this: map: (int +> int) -> .... where +> means a generator. And perhaps we have @> for impure functions as well so we have 3 function types .. and now, since Felix is strict about typing and has "no implicit conversions" .. do you really want to write all those extra higher order functions? Even worse, consider a struct with a member which is a function, you'd need another type if it could be a generator. Unless you have a subtyping rule, such as "all functions are generators" which is obviously the case and a conversion. So it can be done. But then, all your HOF's and structs would just use generators to be most general .. and you might just as well not have the distinction. To do it, we have to have a builtin transformation rule such as: if a HOF accepts a generator it is a generator itself. Unfortunately that rule is wrong .. a trivial example: fun ident[T] (f:T) => f; this is just the identity function Its a pure function EVEN IF the argument is a generator.. Just for your amusement Felix DOES HAVE this type of function: int --> int already. It means "a pointer to a C function". We need that, or we cannot do C callbacks. And it IS a different type to a Felix function: int -> int because the latter is a pointer to a C++ class with an apply method. Felix cheats here. You can pass a int --> int to a HOF expecting a Felix function (but not the other way around). Felix just generates a wrapper which IS a Felix function that calls the C one. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language