all repos — min @ 358c9895fa78019998a3f96bfce24f2a95aa09f5

A small but practical concatenative programming language.

site/contents/_includes/_reference-lang_.md

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
{@ _defs_.md || 0 @}

{#op||append||\* (\*)||(\*)||
Returns a new quotation containing the contents of {{q}} with [\*](class:kwd) appended. #}

{#op||at||(\*) I||\*||
Returns the {{i}}^th element of {{q}}.#}

{#op||bind||\* §||{{null}}||
Binds the specified value (auto-quoted) to an existing symbol {{sl}}.#}

{#op||call||(\*) §||\*?||
Calls operator {{sl}} defined in scope {{q}}. #}

{#op||concat||(2) (1)||(\*)||
Concatenates {{2}} with {{1}}. #}

{#op||debug||{{null}}||{{null}}||
Toggles debug mode. #}

{#op||debug?||{{null}}||B||
Returns {{t}} if debug mode is on, {{f}} otherwise. #}

{#op||define||\* §||{{null}}||
Defines a new symbol {{sl}}, containing the specified value (auto-quoted).#}

{#op||delete||§||{{null}}||
Deletes the specified symbol {{sl}}.#}

{#op||eval||S||\*?||
Parses and interprets {{s}}. #}

{#op||exit||{{null}}||{{null}}||
Exits the program or shell. #}

{#op||first||(\*)||\*||
Returns the first element of {{q}}. #}

{#op||format-error||(E)||S||
Formats the error {{e}} as a string.

> %sidebar%
> Example
> 
> The following: 
> 
> `((error "MyError") (message "This is a test error")) format-error`
> 
> produces: `"This is a test error"`#}

{#op||from-json||S||\*||
Converts a JSON string into {{M -> min}} data.#}

{#op||import||§||{{null}}||
Imports the a previously-loaded module {{sl}}, defining all its symbols in the current scope. #}

{#op||inspect||(\*)||(S+)||
Returns a list of symbols published on {{q}}'s scope. #}

{#op||load||S||\*?||
Parses and interprets the specified {{M}} file {{s}}, adding [.min](class:ext) if not specified. #}

{#op||loglevel||§||{{null}}||
Sets the current logging level to {{sl}}. {{sl}} must be one of the following strings or quoted symbols:

  * debug
  * info
  * notice
  * warn
  * error
  * fatal

> %note%
> Note
> 
> The default logging level is _notice_.
 #}

{#op||module||(\*) §||{{null}}||
Creates a new module {{sl}} based on quotation {{q}}. #}

{#op||module-sigils||(\*)||(S+)||
Returns a list of all sigils defined in module {{q}}.#}

{#op||module-symbols||(\*)||(S+)||
Returns a list of all symbols defined in module {{q}}.#}

{#op||prepend||\* (\*)||(\*)||
Returns a new quotation containing the contents of {{q}} with [\*](class:kwd) prepended. #}

{#op||publish||§ (*)||{{null}}||
Publishes symbol {{sl}} to the scope of [(\*)](class:kwd).
> 
> > %sidebar%
> > Example
> >
> Publish symbol [my-local-symbol](class:kwd) to [ROOT](class:kwd) scope:
> > `'my-local-symbol ROOT publish` #}

{#op||quote||\*||(\*)||
Wraps [\*](class:kwd) in a quotation. #}

{#op||raise||(E)||{{null}}||
Raises the error specified via the dictionary {{e}}.#}

{#op||rest||(\*)||(\*)||
Returns a new quotation containing all elements of the input quotation except for the first. #}

{#op||sigils||{{null}}||(S+)||
Returns a list of all sigils defined in the [ROOT](class:kwd) scope.#}

{#op||source||§||(\*)||
Display the source code of symbol {{sl}} (if it has been implemented a {{M}} quotation). #}

{#op||symbols||{{null}}||(S+)||
Returns a list of all symbols defined in the [ROOT](class:kwd) scope.#}

{#op||to-json||(\*)||S||
Converts a quotation into a JSON string {{s}}.#}


{#op||try||(\*)||\*?||
Evaluates quotation {{q}} as a try/catch/finally block. 
> 
> {{q}} must contain the following elements:
> 
> 1. A quotation containing the code to be evaluated (_try_ block).
> 1. _(optional)_ A quotation containing the code to execute in case of error (_catch_ block).
> 1. _(optional)_ A quotation containing the code to execute after the code has been evaluated, whether an error occurred or not (_finally_ block).
> 
>> %sidebar%
>> Example
>>
>> The following program executed on an empty stack prints the message "Insufficient items on the stack" and pushes 0 on the stack:
>> 
>>       (
>>         (pop)
>>         (format-error puts)
>>         (0)
>>       ) try #}

{#op||unquote||(\*)||\*||
Pushes the contents of quotation {{q}} on the stack. #}

{#op||with||(2) (1)||\*?||
Applies quotation {{2}} within the scope of {{1}}. #}