Salvador de la Puente González (2014-08-20T12:00:32.000Z)
domenic at domenicdenicola.com (2014-09-08T23:16:55.087Z)
Just a little presentation before the proposal. I'm Salvador de la Puente González (you can call me Salva, please). I'm working for Telefonica I+D in Mozilla Firefox OS and I'm a front-end developer, you can know more about me in http://unoyunodiez.com and my github user is https://github.com/lodr Now, these day I was thinking about a generator feature. I have a use case for a transpiler I'm developing: in the source language you have procedures much more like Linux processes. The language have a block sentence *clone* for cloning a procedure. After cloning, father procedure simply ignores the block while coned procedure execute sentences inside. Like an automatized `pid = fork() if (pid != 0) { .... }`. Now I'm addressing this problem from a AST perspective, transpiling procedures to a special generators able to fall through their sentences until reaching a specific yield. But I think it could be easier if I could do something like `generator#clone()` returning a new generator object. This new generator is paused of the same yield as the original one and have a new variable environment with a shallow copy of the original's variable environment. The variable environment's parent chain would be the same as the original one. Notice this is not related with data preservation as most of the objects being used by original generator will be shared with the new one (although this could be addressed as well) but with execution state. In the same way, to provide a complete control over execution state inside generators I would like to propose `generator#goto(yieldLabel)` that could allow the developer to transfer the execution cursor to a labeled yield sentence. The result of the yield sentence could be the extended with the label for that yield. I know it does not suffice to be a cool feature but I think it could trigger very interesting uses cases and applications in backtracking or temper algorithms. What do you think?