lang Module

'

'string string quote

See quote.

'

' quote

See quote.

:

:string string define

See define.

:

: define

See define.

~

~string string delete

See delete.

+

+string string module

See module.

^

^string string call

See call.

^

^ call

See call.

@

@string string bind

See bind.

@

@ bind

See bind.

>

>string string save-symbol

See save-symbol.

<

<string string load-symbol

See load-symbol.

->

-> dequote

See dequote.

=>

=> apply

See apply.

#

#string string quote-bind

See quote-bind.

#

# quote-bind

See quote-bind.

=

=string string quote-define

See quote-define.

=

= quote-define

See quote-define.

apply

quot|dict (a*)|{a*}

This operator can be used on a quotation or a dictionary:

  • If a quotation quot is passed, it returns a new quotation obtained by evaluating each element of quot in a separate stack.
  • If a dictionary dict is passed, it returns a new dictionary obtained by evaluating each symbol of dict in a separate stack.

args

quot

Returns a list of all arguments passed to the current program.

bind

a 'sym

Binds the specified value (auto-quoted) to an existing symbol 'sym.

bool

a bool

Converts a to a boolean value based on the following rules:

  • If a is a boolean value, no conversion is performed.
  • If a is a non-zero numeric value, it is converted to true, otherwise it is converted to false.
  • If a is a non-empty quotation, it is converted to true, otherwise it is converted to false.
  • If a is a non-empty string or not "false", it is converted to true, otherwise it is converted to false.

call

dict 'sym a*

Calls operator 'sym defined in dictionary dict.

case

((quot1 quot2)*) a*

This operator takes a quotation containing n different conditional branches.

Each branch must be a quotation containing two quotations, and it is processed as follows:

  • if quot1 evaluates to true, then the quot2 is executed.
  • if quot1 evaluates to false, then the following branch is processed (if any).

define

a 'sym

Defines a new symbol 'sym, containing the specified value (auto-quoted if not already a quotation).

defined?

'sym bool

Returns true if 'sym is defined, false otherwise.

delete

'sym

Deletes the specified symbol 'sym.

dequote

quot a*

Pushes the contents of quotation quot on the stack.

eval

string a*

Parses and interprets string.

exit

int

Exits the program or shell with int as return code.

expect

quot1 quot2

Validates the first n elements of the stack against the type descriptions specified in quot1 (n is quot1’s length) and if all the elements are valid returns them wrapped in quot2 (in reverse order).

Tips

  • You can specify a typed dictionary by prepending the type name with dict:. Example: dict:socket
  • You can specify two or more matching types by separating the type names with a pipe: string|quot

float

a float

Converts a to an integer value based on the following rules:

  • If a is true, it is converted to 1.0.
  • If a is false, it is converted to 0.0.
  • If a is a integer, it is converted to float value.
  • If a is a float, no conversion is performed.
  • If a is a string, it is parsed as a float value.

foreach

quot1 quot2 a*

Applies the quotation quot2 to each element of quot1.

format-error

dict:error string

Formats the error dict:error as a string.

from-json

string a*

Converts a JSON string into min data.

if

quot1 quot2 quot3 a*

If quot1 evaluates to true then evaluates quot2, otherwise evaluates quot3.

import

'sym

Imports the a previously-loaded module 'sym, defining all its symbols in the current scope.

int

a int

Converts a to an integer value based on the following rules:

  • If a is true, it is converted to 1.
  • If a is false, it is converted to 0.
  • If a is an integer, no conversion is performed.
  • If a is a float, it is converted to an integer value by truncating its decimal part.
  • If a is a string, it is parsed as an integer value.

linrec

quot1 quot2 quot3 quot4 a*

Implements linear recursions as follows:

  1. Evaluates quot1.
    • If quot1 evaluates to true, then it evaluates quot2.
    • Otherwises it executes quot3 and recurses using the same four quotations.
  2. Finally, it executes quot4.

lite?

bool

Returns true if min was built in lite mode.

load

'sym a*

Parses and interprets the specified min file, adding .min if not specified.

load-symbol

'sym a*

Loads the contents of symbol 'sym from the .min_symbols file.

loglevel

'sym

Sets the current logging level to 'sym. 'sym must be one of the following strings or quoted symbols:

  • debug
  • info
  • notice
  • warn
  • error
  • fatal

Note

The default logging level is notice.

module

dict 'sym

Creates a new module 'sym based on dictionary dict.

scope-sigils

dict (string*)

Returns a list of all sigils defined in dictionary dict.

scope-symbols

dict (string*)

Returns a list of all symbols defined in dictionary dict.

opts

dict

Returns a dictionary of all options passed to the current program, with their respective values.

parse

string quot

Parses string and returns a quoted program quot.

prompt

string

This symbol is used to configure the prompt of the min shell. By default, it is set to the following quotation:

("[$1]$$ " (.) => %)

Unlike other predefined symbols, this symbol is unsealed, which means it can be modified.

publish

'sym dict

Publishes symbol 'sym to the scope of dict.

quote

a (a)

Wraps a in a quotation.

quote-bind

a 'sym

Quotes a and binds the quotation to the existing symbol 'sym.

quote-define

a 'sym

Quotes a and assigns the quotation to the symbol 'sym, creating it if not already defined.

raise

dict:error

Raises the error specified via the dictionary dict:error.

read

'sym quot

Reads and parses the specified min file 'sym and returns a quoted program quot.

remove-symbol

'sym

Removes the symbol 'sym from the .min_symbols file.

ROOT

quot

Returns an empty quotation holding a reference to the ROOT scope.

Tip

This symbol is very useful in conjunction with the with operator.

save-symbol

'sym

Saves the contents of symbol 'sym to the .min_symbols file.

seal

'sym

Seals symbol 'sym, so that it cannot be re-assigned.

set-type

dict 'sym dict

Sets the type for dictionary dict to 'sym.

sigils

(string*)

Returns a list of all sigils defined in the ROOT scope.

source

'sym quot

Display the source code of symbol 'sym (if it has been implemented a min quotation).

stored-symbols

(string*)

Returns a quotation containing all symbols stored in the .min_symbols file.

string

a string

Converts a to its string representation.

symbols

(string*)

Returns a list of all symbols defined in the ROOT scope.

tap

a quot a

Performs the following operations:

  1. Removes a from the stack.
  2. For each quotation defined in quot (which is a quotation of quotations each requiring one argument and returning one argument):
    1. Pushes a back to the stack.
    2. Dequotes the quotation and saves the result as a.
  3. Push the resulting a back on the stack.

tap!

a quot a

Performs the following operations:

  1. Removes a from the stack.
  2. For each quotation defined in quot (which is a quotation of quotations each requiring one argument and returning one argument):
    1. Pushes a back to the stack.
    2. Dequotes the quotation and saves the result as a.

times

quot int a*

Applies the quotation quot int times.

to-json

quot string

Converts quot into a JSON string string.

try

(quot1 quot2? quot3?) a*

Evaluates a quotation as a try/catch/finally block.

The must contain the following elements:

  1. A quotation quot1 containing the code to be evaluated (try block).
  2. (optional) A quotation quot2 containing the code to execute in case of error (catch block).
  3. (optional) A quotation quot3 containing the code to execute after the code has been evaluated, whether an error occurred or not (finally block).

unless

quot1 quot2 a*

If 1 evaluates to false then evaluates 2.

unseal

'sym

Unseals symbol 'sym, so that it can be re-assigned.

version

string

Returns the current min version number.

when

quot1 quot2 a*

If quot1 evaluates to true then evaluates quot2.

while

quot1 quot2 a*

Executes quot2 while quot1 evaluates to true.

with

quot1 quot2 a*

Applies quotation quot1 within the scope of quot2.