all repos — min @ ed43d8c32b0c345bdf27c5eb2322f845b00eaa68

A small but practical concatenative programming language.

Implemented --.
h3rald h3rald@h3rald.com
Fri, 25 Dec 2020 02:30:08 +0000
commit

ed43d8c32b0c345bdf27c5eb2322f845b00eaa68

parent

bd2f22c6a55cacffd7aa30ed8e578ed63ce917a1

3 files changed, 25 insertions(+), 0 deletions(-)

jump to
M lib/min_lang.nimlib/min_lang.nim

@@ -791,6 +791,12 @@ def.symbol("expect") do (i: In):

var q: MinValue i.reqQuotationOfSymbols q i.push(i.expect(q.qVal.mapIt(it.getString())).reversed.newVal) + + def.symbol("reverse-expect-dequote") do (i: In): + var q: MinValue + i.reqQuotationOfSymbols q + var req = i.expect(q.qVal.reversed.mapIt(it.getString())).newVal + i.dequote(req) def.symbol("infix-dequote") do (i: In): let vals = i.expect("quot")

@@ -944,6 +950,9 @@ i.push("quote".newSym)

def.symbol("->") do (i: In): i.push("dequote".newSym) + + def.symbol("--") do (i: In): + i.push("reverse-expect-dequote".newSym) def.symbol("=>") do (i: In): i.push("apply".newSym)
M next-release.mdnext-release.md

@@ -7,3 +7,4 @@ * Fixed error handling and stack trace for **start-server** symbol.

* Added the possibility to bundle assets in a compiled min program by specifying tbe **-a** (or **--asset-path**) option. * Added **expect-empty-stack** (**=-=**) symbol. * Added **null** data type, added **null?** symbol. +* Added **reverse-expect-dequote** (**\-\-**) symbol.
M site/contents/reference-lang.mdsite/contents/reference-lang.md

@@ -32,6 +32,8 @@ {#sig||<||load-symbol#}

{#alias||->||dequote#} +{#alias||--||reverse-expect-dequote#} + {#alias||>>||prefix-dequote#} {#alias||><||infix-dequote#}

@@ -336,6 +338,19 @@ Removes the symbol {{sl}} from the [.min\_symbols](class:file) file. #}

{#op||require||{{sl}}||{{d}}|| Parses and interprets (in a separater interpreter) the specified {{m}} file {{sl}}, adding [.min](class:ext) if not specified, and returns a module dictionary {{d}} containing all the symbols defined in {{sl}}. #} + +{#op||reverse-expect-dequote||{{q1}}||{{q2}}|| +> Validates the first _n_ elements of the stack against the type descriptions specified in {{q1}} (_n_ is {{q1}}'s length) in reverse order and if all the elements are valid restores them on the stack. +> +> %sidebar% +> Example +> +> The following program maps the three values on the stack to three symbols, after validating them: +> +> 1 3.5 true +> (int float bool) -- :my-int :my-float :my-bool + #} + {#op||ROOT||{{none}}||{{d}}|| Returns a module holding a reference to the [ROOT](class:kwd) scope.