On 10/08/2014, at 10:52 AM, srean wrote: > Just to clarify, if a function
.. like thingo ... > mutates state held in its closure it has to be a generator, is that correct ? Yes, because functions cannot possibly return different values each invocation unless they depend on externally modified variables, because they're not allowed to modify anything (except transiently). Let me say that again, because it illustrates a problem in Felix: A pure function depends only on its parameters and so cannot depend on external variables. A Felix function can depend on external variables: var x = 1; fun getx() => x; println$ getx(); ++x; println$ getx(); So getx isn't pure. Even so it isn't allowed to modify x. A generator IS allowed to have side effects. The problem is that there is no notation for "pure function". I mean, trivially .. I can't think of a short name for it such as pfn sin: double -> double; // pure function What i was going to do was say "fun" means pure, and use acc (accessor) > I had not realized this because it needs some reading between the lines. I > think a good guideline is that if two different calls to a function can > return different values it has to be a generator. Except as above that isn't true if something ELSE modifies the state it depends on. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language