Updates to docs and logo
h3rald h3rald@h3rald.com
Thu, 01 Apr 2021 20:17:23 +0200
12 files changed,
135 insertions(+),
75 deletions(-)
M
README.md
→
README.md
@@ -1,2 +1,14 @@
-# mn -A truly minimal concatenative programming language + +<p align="center"><img align="center" width="350" src="logo.svg"/></p> +<p align="center"> + <b>A truly minimal<br>concatenative programming language</b> + <br><br> + <img src="https://img.shields.io/badge/nim-powered-yellow.svg?link=https://nim-lang-org"> + <img src="https://img.shields.io/github/release/h3rald/mn/all.svg"> + <img src="https://img.shields.io/github/license/h3rald/mn.svg"> +</p> + +--- + +► For more info, go to <https://min-lang.org>. +
M
docs/about.md
→
docs/about.md
@@ -4,24 +4,26 @@ title: "About"
----- {@ _defs_.md || 0 @} -**mn** is a concatenative, fully-homoiconic, functional, interpreted programming language. +{{m}} is a concatenative, fully-homoiconic, functional, interpreted programming language. This basically means that: * It is based on a somewhat obscure and slightly unintuitive programming paradigm, think of [Forth](http://www.forth.org/), [Factor](http://factorcode.org/) and [Joy](http://www.kevinalbrecht.com/code/joy-mirror/) but with parentheses for an extra [Lisp](https://common-lisp.net/)y flavor. -* Programs written in mn are actually written using *quotations*, i.e. lists. +* Programs written in {{m}} are actually written using *quotations*, i.e. lists. * It comes with map, filter, find, and loads of other functional goodies. * It is probably slower than the average production-ready programming language. ## Why? -mn is [min](https://min-lang.org) little brother. When I started implementing min, I wanted to create a small but practical programming language you could use for shell scripting and perform common tasks. As more feature requests piled in, I noticed it slowly became more and more comprehensive and _batteries-included_: I slowly swapped small, less-unknown and somewhat quirky libraries for regular expressions, compression etc. to more complete and well-known ones, I added HTTPS support (and OpenSSL), and then improved runtime checks when creating symbols, enhanced the type system, and so on. While min can now be used on its own to create quite complex programs, it became less minimal that originally intended. +{{m}} is [min](https://min-lang.org)'s little brother. When I started implementing min, I wanted to create a small but practical programming language you could use for shell scripting and perform common tasks. As more feature requests piled in, I noticed it slowly became more and more comprehensive and _batteries-included_: I slowly swapped small, less-unknown and somewhat quirky libraries used for regular expressions, compression etc. with more complete and well-known ones, added HTTPS support (and OpenSSL), improved runtime checks when creating symbols, enhanced the type system, and so on. While min can now be used on its own to create quite complex programs, it became less minimal than originally intended. -I tried to add compilation variants to reduce the modules to include but that made it more difficult to maintain and still included complex constructs like dictionaries and the full type system, so one day I decided to... fork it! +I tried to add compilation variants to reduce the modules to include but that made it more difficult to maintain and still included complex constructs like dictionaries and the full type system, so one day I decided to... fork it! And that's how {{m}} was born. + +Is {{m}} the *successor* of min? No! As I said, it is min's little brother, and it has its own (somewhat more minimalist) life. If you want to create a quick script to glue some shell commands together, then {{m}} is definitely the fastest way to do so. If you want to use the concatenative paradigm to create more complex applications, then min comes with a much bigger toolbox. ## How? -mn is developed entirely in [Nim](https://nim-lang.org) and started off as a fork of the [https://min-lang.org](min) programming language. I took the v0.35.0 codebase and started removing stuff, including the only vowel included in the name. What else was removed you ask? Let's see... compared to min, mn: +{{m}} is developed entirely in [Nim](https://nim-lang.org) and started off as a fork of the [min](https://min-lang.org) programming language. I took the v0.35.0 codebase and started removing stuff, including the only vowel used in the language name. What else was removed you ask? Let's see... compared to min, {{m}}: * does not have dictionaries * does not have modules@@ -36,7 +38,7 @@ * does not have error handling, i.e. a try/catch mechanism
* does not have any built-in support for networking, cryptography, etc. * does not have a fancy REPL with autocompletion -What *does* it have then? Well: +What *does* it have then? Well, {{m}} provides: * exactly 70 symbols, nearly all of which are borrowed from min * file reading/writing (via the {#link-symbol||read#} and {#link-symbol||write#} symbols)@@ -48,8 +50,8 @@ * a basic REPL
## Who? -mn was created and implemented by [Fabio Cevasco](https://h3rald.com), +{{m}} was created and implemented by [Fabio Cevasco](https://h3rald.com), ## When? -mn source code [repository](https://github.com/h3rald/mn) was created on March 23^rd^ 2021.+{{m}} source code [repository](https://github.com/h3rald/mn) was created on March 23^rd 2021.
M
docs/get-started.md
→
docs/get-started.md
@@ -4,7 +4,7 @@ title: "Get Started"
----- {@ _defs_.md || 0 @} -You can download one of the following pre-built mn binaries: +You can download one of the following pre-built {{m}} binaries: - {#release||{{$version}}||macosx||macOS||x64#} - {#release||{{$version}}||windows||Windows||x64#}@@ -14,22 +14,22 @@ {#release -> [mn v$1 for $3 ($4)](https://github.com/h3rald/mn/releases/download/v$1/mn_v$1_$2_$4.zip) #}
## Building from source -Alternatively, you can build mn from source as follows: +Alternatively, you can build m from source as follows: -1. Download and install [nim](https://nim-lang.org). -3. Clone the mn [repository](https://github.com/h3rald/mn). -4. Navigate to the mn repository local folder. +1. Download and install [Nim](https://nim-lang.org). +3. Clone the {{m}} [repository](https://github.com/h3rald/mn). +4. Navigate to the {{m}} repository local folder. 6. Run **./build.sh**. ## Running the mn REPL -To start the mn REPL, run [mn](class:cmd) with no arguments. You will be presented with a prompt displaying the path to the current directory: +To start the {{m}} REPL, run [mn](class:cmd) with no arguments. You will be presented with a prompt displaying the path to the current directory: > %mn-terminal% > mn v$version > [::](class:prompt) -You can type mn code and press [ENTER](class:kbd) to evaluate it immediately: +You can type {{m}} code and press [ENTER](class:kbd) to evaluate it immediately: > %mn-terminal% > [::](class:prompt) 2 2 +@@ -43,16 +43,16 @@ > [::](class:prompt) dup \*
> 16 > [::](class:prompt) -To exit mn shell, press [CTRL+C](class:kbd) or type [0 exit](class:cmd) and press [ENTER](class:kbd). +To exit {{m}} shell, press [CTRL+C](class:kbd) or type [0 exit](class:cmd) and press [ENTER](class:kbd). -## Executing a mn Program +## Executing an mn Program -To execute a mn script, you can: +To execute a {{m}} script, you can: - Run `mn -e:"... program ..."` to execute a program inline. - Run `mn myfile.mn` to execute a program contained in a file. -mn also supports running programs from standard input, so the following command can also be used (on Unix-like system) to run a program saved in [myfile.mn](class:file): +{{m}} also supports running programs from standard input, so the following command can also be used (on Unix-like system) to run a program saved in [myfile.mn](class:file): > %mn-terminal% >
M
docs/learn-control-flow.md
→
docs/learn-control-flow.md
@@ -4,8 +4,7 @@ title: "Learn: Control Flow"
----- {@ _defs_.md || 0 @} -The {#link-module#} provide some symbols that can be used for the most common control flow statements. Unlike most programming languages, mn does not differentiate between functions and statements -- control flow statements are just ordinary symbols that manipulate the main stack. - +{{m}} provides some symbols that can be used for the most common control flow statements. Unlike most programming languages, {{m}} does not differentiate between functions and statements -- control flow statements are just ordinary symbols that manipulate the main stack. ## Conditionals@@ -14,21 +13,21 @@
For example, consider the following program: ( - "unknown" (os) let + "Unknown" (system) let [uname] (uname) let (uname "MINGW" indexof -1 !=) - ("windows" (os) bind) + ("Windows" (system) bind) when (uname "Linux" indexof -1 !=) - ("linux" (os) bind) + ("Linux" (system) bind) when (uname "Darwin" indexof -1 !=) - ("macosx" (os) bind) + ("macOS" (system) bind) when - "The current OS is $#" (os) interpolate puts + "The current OS is $#" (system) interpolate puts ) (display-os) lambda -This program defines a symbol `display-file-info` that execute the **uname** system command to discover the operating system and outputs a message. +This program defines a symbol `display-os` that execute the **uname** system command to discover the operating system and outputs a message. ## Loops
M
docs/learn-definitions.md
→
docs/learn-definitions.md
@@ -7,20 +7,20 @@
Being a concatenative language, {{m}} does not really need named parameters or variables: symbols just pop elements off the main stack in order, and that's normally enough. There is however one small problem with the traditional concatenative paradigm; consider the following program for example: dup - () cons "Compiling on $#..." swap interpolate puts pop - () cons "nim --os:$# c test.nim" swap interpolate run + () cons "Compiling in $# mode..." swap interpolate puts pop + () cons "nim -d:$# c test.nim" swap interpolate run -This program takes an operating system indetifier (windows, linux, osx) and attempts to build the file **test.nim** for it. Sure, it is remarkable that no variables are needed for such a program, but it is not very readable: because no variables are used, it is often necessary to make copies of elements and push them to the end of the stack -- that's what the {#link-symbol||dup#} and {#link-symbol||swap#} are used for. +This program takes an string containing either "release" or "development" and attempts to build the file **test.nim** for it. Sure, it is remarkable that no variables are needed for such a program, but it is not very readable: because no variables are used, it is often necessary to make copies of elements and push them to the end of the stack -- that's what the {#link-symbol||dup#} and {#link-symbol||swap#} are used for. The good news is that you can use the {#link-symbol||let#} symbol to define new symbols, and symbols can also be set to literals of course. Consider the following program: - (os) let - "Compiling on $#..." (os) interpolate puts pop - "nim --os:$# c test.nim" (os) interpolate run + (mode) let + "Compiling in $# mode..." (mode) interpolate puts pop + "nim -d:$# c test.nim" (mode) interpolate run -In this case, the first element on the stack is saved to a symbol called **os**, which is then used whenever needed in the rest of the program. +In this case, the first element on the stack is saved to a symbol called **mode**, which is then used whenever needed in the rest of the program. ## Lexical scoping and binding
M
docs/learn-extending.md
→
docs/learn-extending.md
@@ -7,11 +7,11 @@
{{m}} provides a fairly very basic standard library. If you want to extend it, you basically have the following options: * Implementing new {{m}} symbols using {{m}} itself -* Embedding mn in your [Nim](https://nim-lang.org) program +* Embedding {{m}} in your [Nim](https://nim-lang.org) program ## Implementing new mn symbols using mn itself -When you just want to create more high-level mn symbol using functionalities that are already available in mn, the easiest way is to create your own reusable mn symbols in separate files. +When you just want to create more high-level {{m}} symbol using functionalities that are already available in mn, the easiest way is to create your own reusable {{m}} symbols in separate files. ```@@ -31,7 +31,7 @@ ```
## Embedding mn in your Nim program -If you'd like to use {{m}} as a scripting language within your own program, and maybe extend it by implementing additional symbols, you can use mn as a Nim library. +If you'd like to use {{m}} as a scripting language within your own program, and maybe extend it by implementing additional symbols, you can use {{m}} as a Nim library. To do so:@@ -64,9 +64,9 @@ ```
Then you need to: -4. Instantiate a new mn interpreter using the `newMnInterpreter` proc. +4. Instantiate a new {{m}} interpreter using the `newMnInterpreter` proc. 5. Run the `proc` used to define the module. -6. Call the `interpret` method to interpret a mn file or string: +6. Call the `interpret` method to interpret a {{m}} file or string: ``` proc interpret(hs: HastySite, file: string) =@@ -78,4 +78,4 @@
> %tip% > Tip > -> For more information on how to create new symbols with Nim, have a look in the [lang.nim](https://github.com/h3rald/mn/tree/master/mnpkg/lang.nim) of the mn repository, which contains all the mn symbols included in mn. +> For more information on how to create new symbols with Nim, have a look in the [lang.nim](https://github.com/h3rald/mn/tree/master/mnpkg/lang.nim) file in the {{m}} repository, which contains all the symbols included in {{m}}.
M
docs/learn-operators.md
→
docs/learn-operators.md
@@ -10,7 +10,7 @@ * Manipulate elements on the stack
* Perform operations on data * Provide side effects (read/print to standard input/output/files, etc.) -An mn symbol is a single word that is either provided by mn like `dup` or defined by the user. User-defined symbols must: +An {{m}} symbol is a single word that is either provided by {{m}} like `dup` or defined by the user. User-defined symbols must: * Start with a letter * Contain zero or more letters, numbers and/or underscores.@@ -21,7 +21,7 @@ (dup *) (square) lambda
Note that this feels like using {#link-symbol||let#}, but the main difference between {#link-symbol||lambda#} and {#link-symbol||let#} is that `lambda` only works on quotations and it doesn't auto-quote them, so that they are immediately evaluated when the corresponding symbol is pushed on the stack. -> %tip +> %tip% > Tip > > You can use {#link-symbol||lambda-bind#} to re-set a previously set lambda.
M
docs/learn.md
→
docs/learn.md
@@ -4,9 +4,9 @@ title: "Learn"
----- {@ _defs_.md || 0 @} -{{m}} is a stack-based, concatenative programming language that uses postfix notation. If you already know [Forth](http://www.forth.org/), [Factor](http://factorcode.org/) or [Joy](http://www.kevinalbrecht.com/code/joy-mirror/), or if you ever used an [RPN](https://en.wikipedia.org/wiki/Reverse_Polish_notation) calculator, then mn will look somewhat familiar to you. +{{m}} is a stack-based, concatenative programming language that uses postfix notation. If you already know [Forth](http://www.forth.org/), [Factor](http://factorcode.org/) or [Joy](http://www.kevinalbrecht.com/code/joy-mirror/), or if you ever used an [RPN](https://en.wikipedia.org/wiki/Reverse_Polish_notation) calculator, then {{m}} will look somewhat familiar to you. -If not, well, here's how a short mn program looks like: +If not, well, here's how a short {{m}} program looks like: ; This is a comment (1 2 3 4 5) (dup *) map
D
docs/reference-time.md
@@ -1,28 +0,0 @@
------ -content-type: "page" -title: "time Module" ------ -{@ _defs_.md || 0 @} - -{#op||now||{{none}}||{{flt}}|| -Returns the current time as Unix timestamp with microseconds. #} - -{#op||timestamp||{{none}}||{{i}}|| -Returns the current time as Unix timestamp. #} - -{#op||timeinfo||{{i}}||{{tinfo}}|| -Returns a timeinfo dictionary from timestamp {{i}}. #} - -{#op||to-timestamp||{{tinfo}}||{{i}}|| -Converts the timeinfo dictionary {{tinfo}} to the corresponding Unix timestamp. #} - -{#op||datetime||{{i}}||{{s}}|| -Returns an ISO 8601 string representing the combined date and time in UTC of timestamp {{i}}. #} - -{#op||tformat||{{i}} {{s}}||{{s}}|| -> Formats timestamp {{i}} using string {{s}}. -> -> > %tip% -> > Tip -> > -> > For information on special characters in the format string, see the [format](https://nim-lang.org/docs/times.html#format,TimeInfo,string) nim method. #}
M
docs/reference.md
→
docs/reference.md
@@ -6,7 +6,7 @@ {@ _defs_.md || 0 @}
## Notation -The following notation is used in the signature of all mn symbols: +The following notation is used in the signature of all {{m}} symbols: ### Types and Values
A
logo.svg
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="588" + height="588" + version="1.1" + id="svg40" + sodipodi:docname="logo.svg" + inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"> + <metadata + id="metadata46"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs44" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1920" + inkscape:window-height="1013" + id="namedview42" + showgrid="false" + inkscape:zoom="1.4268707" + inkscape:cx="294" + inkscape:cy="294" + inkscape:window-x="-9" + inkscape:window-y="-9" + inkscape:window-maximized="1" + inkscape:current-layer="svg40" /> + <!-- Created with Method Draw - http://github.com/duopixel/Method-Draw/ --> + <path + d="M 253.51912,401.57862 29.104504,428.22133 253.64081,454.17161 476.22708,427.71587 Z" + fill="#64b558" + id="svg_2" + style="stroke-width:5.08435" /> + <path + d="M 253.4564,374.47169 29.041789,401.11441 253.57809,427.06468 476.16436,400.60895 Z" + fill="#4a923b" + id="svg_3" + style="stroke-width:5.08435" /> + <path + d="M 253.39744,348.98563 28.982823,375.62834 253.51912,401.57862 476.10539,375.12288 Z" + fill="#247b1f" + id="svg_4" + style="stroke-width:5.08435" /> + <path + d="m 28.544367,159.15793 40.255591,-0.0651 0.02604,16.10253 q 11.610005,-12.18529 19.833497,-16.49299 8.759279,-4.48702 21.999365,-4.50844 29.52105,-0.0477 46.73812,25.68867 18.92331,-25.79486 51.30753,-25.84723 58.86301,-0.0952 58.97847,71.29257 l 0.17419,107.70695 -40.43491,0.0654 -0.15654,-96.79331 q -0.0405,-25.04814 -6.14046,-35.41521 -6.27877,-10.54596 -20.59245,-10.52281 -16.63932,0.0269 -24.22239,12.56331 -7.5838,12.5364 -7.53895,40.26811 l 0.14554,89.99453 -40.43476,0.0654 -0.15567,-96.25659 q -0.0752,-46.51786 -26.91302,-46.47446 -16.996952,0.0275 -24.75891,12.74263 -7.76268,12.71587 -7.718409,40.08995 l 0.145545,89.99453 -40.255592,0.0651 z" + fill="#93cd8d" + id="svg_5" + style="stroke-width:7.22476" /> + <path + d="m 325.63407,158.5416 40.43477,-0.0654 0.026,16.10253 q 21.07831,-20.96787 47.55775,-21.01069 30.4162,-0.0492 47.44411,19.06747 14.69692,16.25797 14.75652,53.11432 l 0.17275,106.81253 -40.43477,0.0654 -0.15741,-97.33004 q -0.0417,-25.76419 -7.21442,-35.59273 -6.99387,-10.008 -25.42204,-9.97819 -20.03857,0.0324 -28.42604,13.28608 -8.20932,13.07422 -8.15666,45.63653 l 0.136,84.09033 -40.43477,0.0654 z" + fill="#93cd8d" + id="svg_7" + style="stroke-width:7.22476" /> +</svg>