all repos — min @ f25e665d81bbed73b9e83381c585433e12280c8f

A small but practical concatenative programming language.

Docs and tests updates.
h3rald h3rald@h3rald.com
Fri, 22 May 2026 07:21:40 +0200
commit

f25e665d81bbed73b9e83381c585433e12280c8f

parent

761fe344703c6a6bf664b59fd9197f83e39dfdde

M help.jsonhelp.json

@@ -288,7 +288,7 @@ "name": "base?",

"signature": " ==> \"dec\"|\"hex\"|\"oct\"|\"bin\"" }, "bind": { - "description": "Binds the specified value (auto-quoted) to an existing symbol 'sym.", + "description": "Binds the specified value (auto-quoted) to an existing symbol 'sym.\r\n \r\n \r\n Tip\r\n \r\n This symbol supports dot notation and can be used to define keys within dictionaries.", "kind": "symbol", "module": "global", "name": "bind",

@@ -484,7 +484,7 @@ "name": "decode-url",

"signature": "'sym ==> str" }, "define": { - "description": "Defines a new symbol 'sym, containing the specified value.", + "description": "Defines a new symbol 'sym, containing the specified value.\r\n \r\n \r\nTip\r\n\r\n This symbol supports dot notation and can be used to define keys within dictionaries.", "kind": "symbol", "module": "global", "name": "define",

@@ -587,6 +587,13 @@ "kind": "symbol",

"module": "dict", "name": "keys", "signature": "dict ==> (str*)" + }, + "dict.lambda": { + "description": "Sets the value of the 'sym of dict1 to quot, which will be treated as an operator, and returns the modified dictionary dict. \r\n \r\n \r\n Example\r\n \r\n The following program:\r\n \r\n {} (dup *) 'square dict.lambda\r\n\r\n Returns the following dictionary:\r\n\r\n {(dup *) ^square}", + "kind": "symbol", + "module": "dict", + "name": "lambda", + "signature": "dict quot 'sym ==> dict" }, "dict.pairs": { "description": "Returns a quotation containing a quotation for each value/key pair (value first, key second) of dictionary dict. \r\n \r\n \r\n Example\r\n\r\n A The following program returns ((1 \"a\") (2 \"b\")):\r\n {1 :a 2 :b} dict.pairs",

@@ -1022,6 +1029,13 @@ "module": "global",

"name": "get-env", "signature": "'sym ==> str" }, + "get-raw": { + "description": "Returns the _n^th_ element of quot (zero-based) wrapped in a dict:rawval.", + "kind": "symbol", + "module": "global", + "name": "get-raw", + "signature": "quot int ==> dict:rawval" + }, "gets": { "description": "Reads a line from STDIN and places it on top of the stack as a string.", "kind": "symbol",

@@ -1289,14 +1303,14 @@ "name": "join",

"signature": "quot 'sym ==> str" }, "lambda": { - "description": "Defines a new symbol 'sym, containing the specified quotation quot. Unlike with define, in this case quot will not be quoted, so its values will be pushed on the stack when the symbol 'sym is pushed on the stack.\r\n \r\n Essentially, this symbol allows you to define an operator without any validation of constraints and bind it to a symbol.", + "description": "Defines a new symbol 'sym, containing the specified quotation quot. Unlike with define, in this case quot will not be quoted, so its values will be pushed on the stack when the symbol 'sym is pushed on the stack.\r\n \r\n Essentially, this symbol allows you to define an operator without any validation of constraints and bind it to a symbol.\r\n \r\n \r\n Tip\r\n \r\n This symbol supports dot notation and can be used to define lambda keys within dictionaries.", "kind": "symbol", "module": "global", "name": "lambda", "signature": "quot 'sym ==> " }, "lambda-bind": { - "description": "Binds the specified quotation to an existing symbol 'sym which was previously-set via lambda.", + "description": "Binds the specified quotation to an existing symbol 'sym which was previously-set via lambda. \r\n \r\n \r\n Tip\r\n\r\n This symbol supports dot notation and can be used to bind lambda keys within dictionaries.", "kind": "symbol", "module": "global", "name": "lambda-bind",

@@ -1860,7 +1874,7 @@ "description": "Initializes the random number generator using a seed based on the current timestamp.",

"kind": "symbol", "module": "global", "name": "randomize", - "signature": " ==> {{null}" + "signature": " ==> null" }, "range": { "description": "Takes a quotation quot1 of two or three integers in the form of *start*, *end* and an optional *step* (1 if not specified) and generates the sequence and returns the resulting quotation of integers quot2.",

@@ -1875,13 +1889,6 @@ "kind": "symbol",

"module": "global", "name": "raw-args", "signature": " ==> quot" - }, - "raw-get": { - "description": "Returns the _n^th_ element of quot (zero-based) wrapped in a dict:rawval.", - "kind": "symbol", - "module": "global", - "name": "raw-get", - "signature": "quot int ==> dict:rawval" }, "reduce": { "description": "Combines each successive element of quot1 using quot2. On the first iteration, the first two inputs processed by quot2 are a1 and the first element of quot1.\r\n \r\n \r\n Example\r\n \r\n The following program leaves 120 on the stack:\r\n \r\n (1 2 3 4 5) \r\n 1 (*) reduce",
M min.vimmin.vim

@@ -1,8 +1,8 @@

" Vim syntax file " Language: min " Maintainer: Fabio Cevasco -" Last Change: 28 Oct 2024 -" Version: 0.46.0 +" Last Change: 22 May 2026 +" Version: 0.47.0 if exists("b:current_syntax") finish
M site/contents/learn-definitions.mdsite/contents/learn-definitions.md

@@ -77,5 +77,17 @@ > Note

> > The {#link-global-operator||unseal-symbol#} operator can be used to effectively un-seal a previously-sealed symbol. Use with caution! +## Dot Notation + +The {#link-global-operator||define#}, {#link-global-operator||lambda#}, {#link-global-operator||bind#}, {#link-global-operator||lambda-bind#} operators and corresponding sigils suppot _dot notation_, i.e. can be used to define or bind values or lambdas _within dictionaries_, by specifying their path using dots. + +In other words, consider the following code which prints `24`: + + {4 :value (stack.dup *) ^square} :example + (stack.dup stack.dup * *) ^example.cube + 2 example.cube example.value example.square + :example.value + example.value puts! + +Here, we are defining a lambda key called `cube` within the `example` dictionary, using dot notation to access its keys and execute lambdas, and then resetting `example.value` to the result of the operation. {#link-learn||scopes||Scopes#}
M site/contents/learn-operators.mdsite/contents/learn-operators.md

@@ -19,7 +19,7 @@

* Start with a letter or an underscore (\_). * Contain zero or more letters, numbers and/or any of the following characters: `/ ! ? + * _ -` -If a symbol contains a dot (`.`) then it is namespaced by its containing module or dictionary. For example, `fs.dirname` identifies the {#link-operator||fs||dirname#} operator defined in the {#link-module||fs#} module. +If a symbol contains a dot (`.`) then it is namespaced by its containing module or dictionary. For example, `fs.dirname` identifies the {#link-operator||fs||dirname#} operator defined in the {#link-module||fs#} module. This is called _dot notation_. It is possible to define operator symbols using the {#link-global-operator||operator#} symbol. The following min program defines a new symbol called square that duplicates the first element on the stack and multiplies the two elements:
M site/contents/reference-global.mdsite/contents/reference-global.md

@@ -129,7 +129,12 @@ {#op||base?||{{none}}||["dec"|"hex"|"oct"|"bin"](class:kwd)||

Returns the numeric base currently used to represent integers (default: ["dec"](class:kwd)). #} {#op||bind||{{any}} {{sl}}||{{none}}|| -Binds the specified value (auto-quoted) to an existing symbol {{sl}}.#} +> Binds the specified value (auto-quoted) to an existing symbol {{sl}}. +> +> > %tip% +> > Tip +> > +> > This symbol supports dot notation and can be used to define keys within dictionaries. #} {#op||bitand||{{i1}} {{i2}}||{{i3}}|| Computes the bitwise *and* of integer {{i1}} and {{i2}}.#}

@@ -206,7 +211,12 @@ {#op||decode-url||{{sl}}||{{s}}||

URL-decodes {{sl}}, deconding all URL-encoded characters.#} {#op||define||{{any}} {{sl}}||{{none}}|| -Defines a new symbol {{sl}}, containing the specified value.#} +> Defines a new symbol {{sl}}, containing the specified value. +> +> > %tip% +> >Tip +> > +> > This symbol supports dot notation and can be used to define keys within dictionaries. #} {#op||define-sigil||{{any}} {{sl}}||{{none}}|| Defines a new sigil {{sl}}, containing the specified value (auto-quoted if not already a quotation).#}

@@ -506,10 +516,20 @@

{#op||lambda||{{q}} {{sl}}||{{none}}|| > Defines a new symbol {{sl}}, containing the specified quotation {{q}}. Unlike with `define`, in this case {{q}} will not be quoted, so its values will be pushed on the stack when the symbol {{sl}} is pushed on the stack. > -> Essentially, this symbol allows you to define an operator without any validation of constraints and bind it to a symbol.#} +> Essentially, this symbol allows you to define an operator without any validation of constraints and bind it to a symbol. +> +> > %tip% +> > Tip +> > +> > This symbol supports dot notation and can be used to define lambda keys within dictionaries. #} {#op||lambda-bind||{{q}} {{sl}}||{{none}}|| -Binds the specified quotation to an existing symbol {{sl}} which was previously-set via `lambda`. #} +> Binds the specified quotation to an existing symbol {{sl}} which was previously-set via `lambda`. +> +> > %tip% +> > Tip +> > +> > This symbol supports dot notation and can be used to bind lambda keys within dictionaries. #} {#op||last||{{q}}||{{any}}|| Returns the last element of {{q}}. #}
M tests/global.mintests/global.min

@@ -844,6 +844,13 @@ test1.value test1.times3 @test1.value

test1.value 6 == ) test.assert + ( + {4 :value (stack.dup *) ^square} :example + (stack.dup stack.dup * *) ^example.cube + 2 example.cube puts example.value example.square + puts :example.value + example.value 24 == + ) test.assert + test.report ;; Tidy up stack.clear