[Felix-language] generators

2014-12-14 Thread john skaller
Take care! There is a bug in the compiler causing test/regress/rt/generators-01.flx to fail. When I looked at the test I saw the problem instantly. Here's the code: /// //Check generators var cheat : int = 0; gen f():int = { ++ch

Re: [Felix-language] Generators and iterators

2006-09-08 Thread skaller
On Fri, 2006-09-08 at 10:25 -0700, Erick Tryzelaar wrote: > skaller wrote: > > The result: Felix fibres can't deadlock. Finite streams > > are perfectly represented: if a thread tries to read > > past the end of a stream it just disappears, so the > > very question cannot arise. > > > > fyi, I

Re: [Felix-language] Generators and iterators

2006-09-08 Thread Erick Tryzelaar
skaller wrote: > The result: Felix fibres can't deadlock. Finite streams > are perfectly represented: if a thread tries to read > past the end of a stream it just disappears, so the > very question cannot arise. > fyi, I had a case where I think I deadlocked the main thread unexpectedly trying

Re: [Felix-language] Generators and iterators

2006-09-08 Thread skaller
On Sat, 2006-09-09 at 00:15 +1000, skaller wrote: > I didn't *design* 'generators'. Felix designed them. > I just followed his instructions, and implemented them: > he spoke in a dream one night, around the 5th cup > of coffee .. :) To give an idea of how Felix works.. in Stephen M Watt's superb

Re: [Felix-language] Generators and iterators

2006-09-08 Thread skaller
On Fri, 2006-09-08 at 00:21 -0700, Erick Tryzelaar wrote: > 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. Just to try to explain this ag

Re: [Felix-language] Generators and iterators

2006-09-08 Thread skaller
On Fri, 2006-09-08 at 00:48 -0700, Erick Tryzelaar wrote: > Erick Tryzelaar wrote: > > 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 differe

Re: [Felix-language] Generators and iterators

2006-09-08 Thread skaller
On Fri, 2006-09-08 at 00:21 -0700, Erick Tryzelaar wrote: > 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 :) Don't be so sure. The fibres/channels subsume everything that can

Re: [Felix-language] Generators and iterators

2006-09-08 Thread Erick Tryzelaar
Erick Tryzelaar wrote: > 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 ce

Re: [Felix-language] Generators and iterators

2006-09-08 Thread Erick Tryzelaar
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 sl

Re: [Felix-language] Generators and iterators

2006-09-07 Thread skaller
On Fri, 2006-09-08 at 11:54 +1000, skaller wrote: > On Thu, 2006-09-07 at 21:24 -0400, Jacques Carette wrote: > > THE paper to read regarding the efficient compilation of generators and > > iterators is > > http://www.csd.uwo.ca/~watt/pub/reprints/2006-wgp-jflow.pdf > > > > Will do, thanks! Look

Re: [Felix-language] Generators and iterators

2006-09-07 Thread skaller
On Fri, 2006-09-08 at 10:40 +1000, skaller wrote: > Felix now supports first class iterators, as a special > case of generators. Here is an example: Here's more elaborate example: #import union tree = TEmpty | Leaf of int | Node of tree * tree; var examp

Re: [Felix-language] Generators and iterators

2006-09-07 Thread skaller
On Thu, 2006-09-07 at 21:24 -0400, Jacques Carette wrote: > THE paper to read regarding the efficient compilation of generators and > iterators is > http://www.csd.uwo.ca/~watt/pub/reprints/2006-wgp-jflow.pdf > Will do, thanks! Looks good too! -- John Skaller Felix, successor to C++: http://f

Re: [Felix-language] Generators and iterators

2006-09-07 Thread Jacques Carette
THE paper to read regarding the efficient compilation of generators and iterators is http://www.csd.uwo.ca/~watt/pub/reprints/2006-wgp-jflow.pdf Jacques - Using Tomcat but need to do more? Need to support web services, secur

[Felix-language] Generators and iterators

2006-09-07 Thread skaller
Felix now supports first class iterators, as a special case of generators. Here is an example: #import gen f(init:int)(inc:int):int = { var counter = init; again:> counter += inc; yield counter; goto again; } var x = f(40); print$ x(2); endl; // 42 p