On 01/07/2013, at 12:56 AM, srean wrote: > Can the compiler check if a function is accessing any variable outside of its > scope and issue warnings/error when the return value is assigned to a val ? > That would be good.
No, its impossible in general, because functional programming languages have closures (function values) and there's no way to see inside one; all you know is its type. And at present generators and functions have the same type. Felix only "lifts" direct generator calls out of expressions. It doesn't NOT lift calls like g x where g is a variable of function type, because it doesn't know if g is a generator or not. However it usually doesn't matter because closure applications almost invariably use eager evaluation, because, well, once you have a closure that can accept ANY argument of some type, the only way to do that is evaluate the argument and assign it to a slot in the closure. If you want lazy evaluation in a closure you have to explicitly use a function type argument to the closure. > How is C_hack::ignore x implemented, in the library or the language ? [You mean: in the library or the compiler: the "language", i.e. the grammar, is defined IN THE LIBRARY: unlike most languages, the grammar is user defined. This is one reason its hard to "document" the Felix language, because there isn't one!] C_hack is the name of a class. ignore is a polymorphic procedure. It's in the library in lib/std/c_hack.flx. //$ Throw away result of a function call: //$ only useful for C functions that are mainly //$ called for side effects. proc ignore[t]:t = "(void)$t;"; C_hack is one of the classes deliberately NOT opened by default, to force you to write C_hack:: whenever you use a C hack! It's MEANT to be ugly. -- 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