all repos — min @ 952b6d4b20380fc7809c549debe66bc1c31cae8e

A small but practical concatenative programming language.

Documenting new lambda keys, updated ^ sigil/symbol
h3rald h3rald@h3rald.com
Thu, 21 May 2026 14:57:03 +0200
commit

952b6d4b20380fc7809c549debe66bc1c31cae8e

parent

16f9bb6cb2752fb0df4349d08685ac2c9df92f16

2 files changed, 18 insertions(+), 7 deletions(-)

jump to
M minpkg/lib/min_global.nimminpkg/lib/min_global.nim

@@ -539,7 +539,6 @@ let vals = i.expect("'sym", "a")

let sym = vals[0] var q1 = vals[1] var symbol: string - #q1 = @[q1].newVal symbol = sym.getString if not symbol.contains re(USER_PATH_SYMBOL_REGEX): raiseInvalid("Symbol identifier '$1' contains invalid characters." % symbol)

@@ -567,12 +566,10 @@ let sym = vals[0]

var q1 = vals[1] var symbol: string symbol = sym.getString - if not symbol.contains re(USER_SYMBOL_REGEX): + if not symbol.contains re(USER_PATH_SYMBOL_REGEX): raiseInvalid("Symbol identifier '$1' contains invalid characters." % symbol) info "[lambda] $1 = $2" % [symbol, $q1] - if i.scope.symbols.hasKey(symbol) and i.scope.symbols[symbol].sealed: - raiseUndefined("Attempting to redefine sealed symbol '$1'" % [symbol]) - i.scope.symbols[symbol] = MinOperator(kind: minValOp, val: q1, sealed: false, lambda: true) + i.scope.setSymbol(symbol, MinOperator(kind: minValOp, val: q1, sealed: false, lambda: true), false, true) def.symbol("define-sigil") do (i: In): let vals = i.expect("'sym", "quot")

@@ -595,7 +592,6 @@ let vals = i.expect("'sym", "a")

let sym = vals[0] var q1 = vals[1] var symbol: string - #q1 = @[q1].newVal symbol = sym.getString info "[bind] $1 = $2" % [symbol, $q1] let res = i.scope.setSymbol(symbol, MinOperator(kind: minValOp, val: q1))
M site/contents/learn-data-types.mdsite/contents/learn-data-types.md

@@ -22,7 +22,7 @@ : A list of elements, which may also contain symbols. Quotations can be used to create heterogenous lists of elements of any data type, and also to create a block of code that will be evaluated later on (quoted program). Example: (1 2 3 + \*)

command (cmd) : A command string wrapped in square brackets that will be immediately executed on the current shell and converted into the command standard output. Example: `[ls -a]` dictionary (dict) -: A key/value table. Dictionaries are implemented as an immediately-dequoted quotation, are enclosed in curly braces, and are represented by their symbol definitions. Note that dictionary keys must start with `:`and be followed by a double-quoted string, or a single word (which can be written without double quotes). The {#link-module||dict#} provides some operators on dictionaries. +: A key/value table. Dictionaries are implemented as an immediately-dequoted quotation, are enclosed in curly braces, and are represented by their symbol definitions. Note that dictionary keys must start with `:` or `^` and be followed by a double-quoted string, or a single word (which can be written without double quotes). The {#link-module||dict#} provides some operators on dictionaries. > %sidebar% > Example

@@ -34,6 +34,21 @@ > "min" :name

> "concatenative" :paradigm > 2017 :"first release year" > } + +Theere are two types of dictionary keys: +* _define keys_, which are prepended by `:`, which are used to store data, including quotations that will be interpreted as lists of values. +* _lambda keys_, which are prepended by `^`, which are used to store executable code. In this case, a quotation will be immediately executed when accessed. + +> %sidebar% +> Example +> +> The following program prints `16`: +> +> ; First, define a dictionary with a value using a define key +> ; and an operation using a lambda key +> {4 :value (dup *) ^square} :test +> ; When accessing the quotation, it will be executed immediately +> test.value test.square puts Additionally, dictionaries can also be typed to denote complex objects like sockets, errors, etc. For example, the following dictionary defines an error: