Is there a way to use the Vala coroutines to achieve the same effect
as in the following Python snippet:

/////////////////////////////

################
# Python coroutine
###############*


def countdown(n):
   print "Counting down from", n
   while n > 0:
       yield n
       n -= 1
   print "Done counting down"


# Example use
if __name__ == '__main__':
   for i in countdown(10):
       print i

///////////////////////////////

More precisely, is there a way to use a coroutine in order to achieve
an iterator-like effect, namely:

A regular routine would store the results in a data structure
(array,list ...) and return the whole bunch of results, all at once,
when the routine completes.

In the python example, above, partial results can be "returned" (or
rather transmitted using the yield keyword) as soon as they show up in
the coroutine.

- Can a similar effect be achieved in Vala using coroutines (or
something else) ?

Serge.
_______________________________________________
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to