Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "word"

Index

Functions

Const $stackFn

Const $try

Const compile

Const defWord

  • Higher order word. Takes a StackProgram and returns it as StackFn to be used like any word. Unknown stack effect.

    If the optional env is given, uses a shallow copy of that environment (one per invocation) instead of the current one passed by run at runtime. If mergeEnv is true (default), the user provided env will be merged with the current env (also shallow copies). This is useful in conjunction with pushenv and store or storekey() to save results of sub procedures in the main env.

    Note: The provided (or merged) env is only active within the execution scope of the word.

    ( ? -- ? )

    Parameters

    Returns StackFn

Const defWordU

  • Like {@link word}, but automatically calls unwrap on result context to produced unwrapped value/tuple.

    Importatant: Words defined with this function CANNOT be used as part of a larger stack program, only for standalone use.

    Parameters

    • prog: StackProgram

      -

    • Default value n: number = 1

      -

    • Optional env: StackEnv

      -

    • Default value mergeEnv: boolean = true

      -

    Returns (Anonymous function)

Const exec

Const execjs

  • Expects TOS to be a quotation with a vanilla JS function as first element. Calls fn with all remaining items in quot as arguments and pushes result back on d-stack (even if fn returned undefined).

    ( [f ...] -- f(...) )

    Parameters

    Returns StackContext

Const unwrap

  • unwrap(__namedParameters: [Array], n?: number): any
  • Takes a result tuple returned by run and unwraps one or more items from result stack. If no n is given, defaults to single value (TOS) and returns it as is. Returns an array for all other n.

    Parameters

    • __namedParameters: [Array]
    • Default value n: number = 1

      -

    Returns any

Generated using TypeDoc