all repos — min @ 6ea28dd09a5ab9b9d1d1246bd4a045e953475066

A small but practical concatenative programming language.

Moved env symbols and sigils to global.
h3rald h3rald@h3rald.com
Sat, 15 Jun 2024 15:13:33 +0200
commit

6ea28dd09a5ab9b9d1d1246bd4a045e953475066

parent

5db3bcaa53d5d4b9c6640ff9b5cc68f5711b0cd4

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

@@ -1175,6 +1175,20 @@ i.dset(dict, "value", p.a.processTokenValue(t).newVal)

q.add dict i.push q.newVal + def.symbol("get-env") do (i: In): + let vals = i.expect("'sym") + let a = vals[0] + i.push a.getString.getEnv.newVal + + def.symbol("put-env") do (i: In): + let vals = i.expect("'sym", "'sym") + let key = vals[0] + let value = vals[1] + key.getString.putEnv value.getString + + def.symbol("$") do (i: In): + i.pushSym("get-env") + # Sigils def.sigil("'") do (i: In):

@@ -1197,6 +1211,9 @@ i.pushSym("lambda")

def.sigil("~") do (i: In): i.pushSym("lambda-bind") + + def.sigil("$") do (i: In): + i.pushSym("get-env") # Shorthand symbol aliases
M minpkg/lib/min_sys.nimminpkg/lib/min_sys.nim

@@ -60,17 +60,6 @@ i.dset(d, "output", res.output.strip.newVal)

i.dset(d, "code", res.exitCode.newVal) i.push(d) - def.symbol("get-env") do (i: In): - let vals = i.expect("'sym") - let a = vals[0] - i.push a.getString.getEnv.newVal - - def.symbol("put-env") do (i: In): - let vals = i.expect("'sym", "'sym") - let key = vals[0] - let value = vals[1] - key.getString.putEnv value.getString - def.symbol("env?") do (i: In): let vals = i.expect("'sym") let s = vals[0]

@@ -154,12 +143,6 @@ let vals = i.expect("'sym", "'sym")

let dest = vals[0] let src = vals[1] src.getString.createHardlink dest.getString - - def.symbol("$") do (i: In): - i.pushSym("get-env") - - def.sigil("$") do (i: In): - i.pushSym("get-env") def.symbol("unzip") do (i: In): let vals = i.expect("'sym", "'sym")
M next-release.mdnext-release.md

@@ -11,6 +11,7 @@ - The `/` sigil has been removed; use `dget` or symbol dot notation instead.

- The `%` sigil has been removed; use `dset` or symbol dot notation instead. - The `>` sigil has been removed; use `save-symbol` innstead. - The `<` sigil has been removed; use `load-symbol` innstead. +- Moved `get-env`, `put-env`, `$` symbol and `$` sigil from `sys` to `global` module. ### New Features
M site/contents/reference-global.mdsite/contents/reference-global.md

@@ -22,6 +22,10 @@ {#sig||~||lambda-bind#}

{#alias||~||lambda-bind#} +{#sig||$||get-env#} + +{#alias||$||get-env#} + {#sig||@||bind#} {#alias||@||bind#}

@@ -182,6 +186,9 @@ > > At present, only YAML objects containing string values are supported.#}

{#op||gets||{{none}}||{{s}}|| Reads a line from STDIN and places it on top of the stack as a string.#} + +{#op||get-env||{{sl}}||{{s}}|| +Returns environment variable {{sl}}. #} {#op||help||{{sl}}||{{none}}|| Prints the help text for {{sl}}, if available. #}

@@ -352,6 +359,9 @@ > > `'my-local-symbol global publish` #}

{#op||puts||{{any}}||{{any}}|| Prints {{any}} and a new line to STDOUT.#} + +{#op||put-env||{{sl1}} {{sl2}}||{{s}}|| +Sets environment variable {{sl2}} to {{sl1}}. #} {#op||quit||{{none}}||{{none}}|| Exits the program or shell with 0 as return code. #}
M site/contents/reference-sys.mdsite/contents/reference-sys.md

@@ -4,10 +4,6 @@ title: "sys Module"

----- {@ _defs_.md || 0 @} -{#sig||$||get-env#} - -{#alias||$||get-env#} - {#op||admin?||{{none}}||{{b}}|| Returns {{t}} if the program is being run with administrative privileges. #}

@@ -33,9 +29,6 @@

{#op||env?||{{sl}}||{{b}}|| Returns {{t}} if environment variable {{sl}} exists, {{f}} otherwise. #} -{#op||get-env||{{sl}}||{{s}}|| -Returns environment variable {{sl}}. #} - {#op||hardlink||{{sl1}} {{sl2}}||{{none}}|| Creates hardlink {{sl2}} for file or directory {{sl1}}. #}

@@ -56,9 +49,6 @@ Returns the host operating system. It can be one of the following strings: windows, macosx, linux, netbsd, freebsd, openbsd, solaris, aix, standalone. #}

{#op||parent-dir||{{none}}||{{s}}|| Returns the full path to the parent directory. #} - -{#op||put-env||{{sl1}} {{sl2}}||{{s}}|| -Sets environment variable {{sl2}} to {{sl1}}. #} {#op||pwd||{{none}}||{{s}}|| Returns the full path to the current directory. #}