Re: concept from Io language
- Posted by mattlewis (admin) Feb 02, 2009
- 1158 views
Hello, I discovered euphoria sometime ago and find it interesting (specially, due to speed, co-routines, ...)
Concerning co-routines, I found a nice concept in language Io.
From the Io Docs:
So it looks like at least superficially, we have this in the form of multi-tasking
Let's give a small example:
V1 := O1 M1
This line execute method "M1" of object O1 and put result in variable V1. Nothing special ...
V1 := O1 @M1
Do the same but, - create a "future" (a special object) V1 - create a co-routine to execute the method asynchronously - when method is ended, V1 become an variable and get result of method
During execution of method, - the program can continue - If you try to access V1 (ex: V2 := V1 ...), program block untill M1 is finished. - You can of course check if M1 is finished
Future plans for euphoria include the possibility of coroutines, generators and iterators, so this basic idea should happen at some point.
You can for example, do sth like:
V1 := URL with("http://example1.com/") @fetch V2 := URL with("http://example2.com/") @fetch V3 := URL with("http://example3.com/") @fetch . . . do sth with V1 , V2 , V3[snip]
Could that be implemented in euphoria ?
I think the above paradigm could probably be done with the current multitasking API, though I haven't worked with it enough to say how well it would suit what you're describing.
Matt