Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Coroutines in HEAD

7 views
Skip to first unread message

miguel

unread,
Aug 17, 2008, 3:43:37 PM8/17/08
to
I managed to commit an experimental implementation of coroutines in time for
8.6a2. This provides two new commands
::tcl::unsupported::coroutine
::tcl::unsupported::yield

A brief description can be found at http://msofer.com:8080/wiki?name=Coroutines,
otherwise the code in tests/unsupported.test is the only documentation.

Test! Enjoy! Help make it better

Cheers
Miguel

yahalom

unread,
Aug 18, 2008, 2:01:24 AM8/18/08
to
It was good if there was an example of something done both in todays
tcl commands and then with the new commands. This might make the new
commands and coroutines clearer. They are so different from what we
are used to, it makes them hard to grasp. If the example was also with
a verbal explanation of the problem that that solution tries to solve,
it would be even better.

thanks for you work

Alexandre Ferrieux

unread,
Aug 20, 2008, 6:24:24 PM8/20/08
to
On 17 août, 21:43, miguel <mso...@users.sf.net> wrote:
> I managed to commit an experimental implementation of coroutines in time for
> 8.6a2. This provides two new commands
>    ::tcl::unsupported::coroutine
>    ::tcl::unsupported::yield
>
> A brief description can be found athttp://msofer.com:8080/wiki?name=Coroutines,

> otherwise the code in tests/unsupported.test is the only documentation.
>
> Test! Enjoy! Help make it better

Thanks Miguel ! Stackless Tcl : a dream come true for so many of us...

As a first trivial application: "long computation keeping the event-
loop responsive":

proc f {} {
for {SOME} {LONG} {LOOP} {
COMPUTE A FEW THINGS
after idle ff
yield
}
set ::result ...
}
coroutine ff f
vwait ::result

Of course [after idle] can be replaced by [after $some_finite_delay],
allowing to throttle the amount of CPU left idle.

-Alex

miguel

unread,
Aug 23, 2008, 12:17:45 AM8/23/08
to

Colin McCormack has been experimenting with coroutines for his 'wub' webserver.
Quoting him from the chat:

colin lemme show you the source file which implements Co, and that which
implements Rest (doing nearly the same thing, but without coro) ... I think the
difference speaks volumes.
colin http://code.google.com/p/wub/source/browse/trunk/Domains/Co.tcl
colin http://code.google.com/p/wub/source/browse/trunk/Domains/Rest.tcl
colin The complexity of the latter is not entirely due to the model, but is
largely due to it - I had to provide all the context-saving and parsing stuff.
colin I think you'll agree Co (soon to be Coco, dammit) is much cleaner and simpler.
colin I'll have to implement some idle-timeout stuff, which'll add a few dozen
LOC, but it's clean

Arnulf Wiedemann

unread,
Aug 23, 2008, 5:25:49 AM8/23/08
to
miguel wrote:

> yahalom wrote:
>> It was good if there was an example of something done both in todays
>> tcl commands and then with the new commands. This might make the new
>> commands and coroutines clearer. They are so different from what we
>> are used to, it makes them hard to grasp. If the example was also with
>> a verbal explanation of the problem that that solution tries to solve,
>> it would be even better.
>>
>> thanks for you work
>
> Colin McCormack has been experimenting with coroutines for his 'wub'
> webserver. Quoting him from the chat:
>
> colin lemme show you the source file which implements Co, and that which
> implements Rest (doing nearly the same thing, but without coro) ... I
> think the difference speaks volumes.
> colin http://code.google.com/p/wub/source/browse/trunk/Domains/Co.tcl
> colin http://code.google.com/p/wub/source/browse/trunk/Domains/Rest.tcl

the links seem not to work ;-)
Arnulf

miguel

unread,
Aug 23, 2008, 7:59:10 AM8/23/08
to
0 new messages