skaller wrote: > Felix now supports first class iterators, as a special > case of generators. Here is an example:
Thats so awesome. Much better than my streams :) A couple comments on the syntax. First off, python is just about to add sending data back to their generators, but they're using a slightly different to receive data from the calling function. They use the equivalent of "val inc = yield counter;". Did you consider that syntax? The second is related. The overloading of the curry syntax throws me off a little. Using the curry-style argument list may suggest to a newbie that you could do "var x = f 5 10;" to get one result. What about using the "return an anonymous function" syntax? This, along with the first comment would result in something like: ------------------------------------ #import <flx.flxh> gen f(init:int):int->int = { var inc = 0; var counter = init; again:> counter += inc; inc = yield counter; goto again; } Of course, what would it mean to have "gen f(init:int):int" (assuming anonymous function return)? If this is allowed, and actually does just return a single value, then gen doesn't seem all that different from procedures. Your later comments on this suggest that certain forms of gen are really just a reduced form of proc. This suggests that we might be able to merge the functionality, but I'm not sure how possible that is. Finally, the best way to signify the end of the generator still seems to be to wrap things in opt. Is this the fastest way we can signify the end, or are there any compiler-side tricks that can be done to optimize things? > Note the new keyword 'gen' which denotes a generator. > A generator is any function with internal state. > C bindings must also be declared generators if they > access state, for example: malloc(), random() etc are generators. > All class constructors are also generators. Are you referring to it as being conceptually generators, or that you're actually going to change the library to reflect this? -e ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language