Loading ...
Sorry, an error occurred while loading the content.

Implicit coroutines

Expand Messages
  • Mike
    I really love coroutines, especially for handling functions that have wait states or delays. But is it possible to have implicit coroutines, that only appear
    Message 1 of 1 , Dec 2, 2008
    View Source
    • 0 Attachment
      I really love coroutines, especially for handling functions that have
      wait states or delays. But is it possible to have implicit
      coroutines, that only appear when you use "yield"? For example,
      something like:

      Object wait = method(sec, Timer addEvent(sec, self resume))
      fireWeapon := method(fire; wait(0.5); crouch;)

      Now instead of calling "actor @@start", wait would turn the object
      into a coroutine. Implicitly creating coros this way eliminates the
      notion of threads/coroutines, etc. You just code.

      I guess this is going toward actors, but without the inefficiency if
      you don't need every object to be asynchronous.

      Thoughts?

      Mike
    Your message has been successfully submitted and would be delivered to recipients shortly.