Library

Public interface

ResumableFunctions.@resumableMacro

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.IteratorSizeMethod

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

source
Base.eltypeMethod

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

source
ResumableFunctions.transform_argMethod

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
ResumableFunctions.transform_excMethod

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
ResumableFunctions.transform_tryMethod

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