Lorenzo Marcantonio <l.marcanto...@cz-dynamic.it> writes:

> On Thu, Jan 07, 2016 at 12:08:22PM +0000, Mário Luzeiro wrote:

> Some thing like this:
> - Select a tool (suspend for a selection)
> - Other things happens, then user select a thing
> - (restart the tool coroutine) Check thing selected and so on

So to me, this sounds like an excellent use-case for co-routines.

I suppose the idea is to have code something like this (random pseudocode)?

  a = some_prepare_tool_stuff();
  b = other_stuff();
  select = get_selection();
  if (select.aborted) {
    cleanup(a, b);
    return;
  }
  more_tool_stuff(a, b, select.data);

The great thing about co-routines is that it allows to abstract things in
helper functions, like get_selection() above. You don't need to know exactly
how co-routine scheduling will happen inside get_selection, all the details
can be handled inside that function.

In contrast, without co-routines, every such usage will have to be split up
in multiple event handler / callback functions, at each point where event
handling can happen. This breaks the code flow, breaks the data flow, and
makes things a lot harder to read and understand.

Just my two cents,

 - Kristian.

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to