Skip to content

fcall

Input Stack:
key: String
...
Output Stack:
Any
 

Function call by variable name. This is equivalent to :get,:call - it retrieves a stored program from the variable store and executes it. This provides a convenient shorthand for calling stored functions without separate get and call operations.

Parameters

  • key: The variable name containing the program to execute
  • ...: Additional stack items that may be consumed by the called program

Behavior

The operation performs these steps: 1. Retrieves the value stored under key from the variable store 2. Executes the retrieved value as a program using :call semantics 3. The program can consume additional stack items and produce any output

Examples

Storing and calling a function:

duplicate,(,:dup,
),:set,
a,duplicate,:fcall
PosInputOutput
0 duplicate a
1 a a

This example: 1. Sets a program (,:dup,) in variable duplicate 2. Puts a on the stack 3. Calls the duplicate function using :fcall 4. The function duplicates a, resulting in a, a on the stack

Executing a stored function to square the top stack item:

BeforeAfter
square,(,:dup,
:mul,
),:set,
name,sps,:eq,
:sum
square,(,:dup,
:mul,
),:set,
name,sps,:eq,
:sum,
square,:fcall

This stores the squaring program (,:dup,:mul,) in variable square, then calls it using :fcall. The program duplicates the sum result and multiplies the copies together, effectively squaring the value.

  • :call - Execute a program directly from the stack
  • :get - Retrieve values from variable store (used internally by fcall)
  • :set - Store programs in variables for later calling
  • :list - Create program lists for storage and execution