Library

Public interface

Semicoroutines.@resumable — Macro

Macro that transforms a function definition in a finite-statemachine:

  • Defines a new mutable struct that implements the iterator interface and is used to store the internal state.
  • Makes this new type callable having following characteristics:
    • implementents the statements from the initial function definition but;
    • returns at a @yield statement and;
    • continues after the @yield statement when called again.
  • Defines a constructor function that respects the calling conventions of the initial function definition and returns an object of the new type.
source

Internals

Base.IteratorSize — Method

Implements the iteratorsize method of the iterator interface for a subtype of FiniteStateMachineIterator.

source
Base.eltype — Method

Implements the eltype method of the iterator interface for a subtype of FiniteStateMachineIterator.

source
Semicoroutines.transform_arg — Method

Function that replaces a arg = @yield ret statement by

  @yield ret;
  arg = arg_

where arg_ is the argument of the function containing the expression.

source
Semicoroutines.transform_exc — Method

Function that replaces a @yield ret or @yield statement by

  @yield ret
  _arg isa Exception && throw(_arg)

to allow that an Exception can be thrown into a @resumable function.

source
Semicoroutines.transform_try — Method

Function that replaces a try-catch-finally-end expression having a top level @yield statement in the try part

  try
    before_statements...
    @yield ret
    after_statements...
  catch exc
    catch_statements...
  finally
    finally_statements...
  end

with a sequence of try-catch-end expressions:

  try
    before_statements...
  catch
    catch_statements...
    @goto _TRY_n
  end
  @yield ret
  try
    after_statements...
  catch
    catch_statements...
  end
  @label _TRY_n
  finally_statements...
source