all repos — min @ 361a72f48cc2c7b3500bbb410415812673d5f577

A small but practical concatenative programming language.

Merge pull request #66 from drkameleon/master

Minor fixes + Documentation copy editing :)
-- Thanks a lot, @drkameleon 
Fabio Cevasco h3rald@h3rald.com
Mon, 02 Nov 2020 13:14:52 +0100
commit

361a72f48cc2c7b3500bbb410415812673d5f577

parent

d5a433beb31018610820978d92181d6829fb4694

M site/contents/about.mdsite/contents/about.md

@@ -4,24 +4,24 @@ title: "About"

----- {@ _defs_.md || 0 @} -**min** is an concatenative, fully-homoiconic, functional, interpreted programming language. +**min** 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 parethesis for an extra [Lisp](https://common-lisp.net/)y flavor. +* 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 min are actually written using *quotations*, i.e. lists. -* It comes with map, filter, find, map-reduce and loads of other functional goodies. See the {#link-module||seq#} for more. +* It comes with map, filter, find, map-reduce, and loads of other functional goodies. See the {#link-module||seq#} for more. * It is probably slower than the average production-ready programming language. ## Why? Because creating a programming language is something that every programmer needs to do, at some point in life. And also because there are way too few [concatenative](http://concatenative.org/wiki/view/Front%20Page) programming language out there -- so people are likely to be _less_ pissed off than if I made a yet another Lisp instead. -I always wanted to build a minimalist language, but that could also be used for real work and provided a standard library for common tasks and functionalities like regular expression support, cryptography, execution of external programs, shell-like operators and keywords to work with files, and more. +I always wanted to build a minimalist language, but that could also be used for real work and provided a standard library for common tasks and functionalities like regular expression support, cryptography, execution of external programs, shell-like operators, and keywords to work with files, and more. -Also, I wanted it to be fully self-contained, cross platform, and tiny. About 1MB (depending on the platform) is not really tiny, but I feel it's a good compromise compared to the alternatives out there, considering that you only need _one file_ to run any min program. +Also, I wanted it to be fully self-contained, cross-platform, and tiny. About 1MB (depending on the platform) is not really tiny, but I feel it's a good compromise compared to the alternatives out there, considering that you only need _one file_ to run any min program. -I am currently building a static site generator called [HastySite](https://github.com/h3rald/hastysite), that also powers <https://min-lang.org>. HastySite internally uses min as the language to write the [rules](https://github.com/h3rald/min/blob/master/site/rules.min) to process the source files of the site, and also all its [scripts](https://github.com/h3rald/min/tree/master/site/scripts). +I am currently building a static site generator called [HastySite](https://github.com/h3rald/hastysite), which also powers <https://min-lang.org>. HastySite internally uses min as the language to write the [rules](https://github.com/h3rald/min/blob/master/site/rules.min) to process the source files of the site, and also all its [scripts](https://github.com/h3rald/min/tree/master/site/scripts). Finally, I think more and more people should get to know concatenative programming languages, because [concatenative programming matters](http://evincarofautumn.blogspot.it/2012/02/why-concatenative-programming-matters.html).

@@ -29,7 +29,7 @@ ## How?

min is developed entirely in [Nim](https://nim-lang.org) -- the name is (almost) entirely a coincidence. I wanted to call it _minim_ but then shortened it for more... minimalism. -min's parser started off as a fork of Nim's JSON parser -- adapted to process a concatenative programming language with less primitive types than JSON. It is interpreted in the traditional sense: no bytecode, no JIT, just plain read, parse and run. +min's parser started off as a fork of Nim's JSON parser -- adapted to process a concatenative programming language with less primitive types than JSON. It is interpreted in the traditional sense: no bytecode, no JIT, just plain read, parse, and run. ## Who?
M site/contents/download.mdsite/contents/download.md

@@ -68,7 +68,7 @@ To exit min shell, press [CTRL+C](class:kbd) or type [0 exit](class:cmd) and press [ENTER](class:kbd).

> %tip% > -> By default, the min shell provides advanced features like tab-completion, history, etc. If however you run into problems, you can disable these features by running [min -i](class:cmd) instead, and run min shell with a bare-bones REPL. +> By default, the min shell provides advanced features like tab-completion, history, etc. If however, you run into problems, you can disable these features by running [min -i](class:cmd) instead, and run min shell with a bare-bones REPL. ## Executing a min Program
M site/contents/learn-control-flow.mdsite/contents/learn-control-flow.md

@@ -5,7 +5,7 @@ -----

{@ _defs_.md || 0 @} -The {#link-module||lang#} provide some symbols that can be used for the most common control flow statements. Unlike most programming language, min does not differentiate between functions and statements -- control flow statements are just ordinary symbols that manipulate the main stack. +The {#link-module||lang#} provide some symbols that can be used for the most common control flow statements. Unlike most programming languages, min does not differentiate between functions and statements -- control flow statements are just ordinary symbols that manipulate the main stack. ## Conditionals

@@ -31,7 +31,7 @@ ) case

"This is a $1 file." (type) % echo ) :display-file-info -This program defines a symbol `display-file-info` that takes a file name and outputs a message displaying its type, if known. +This program defines a symbol `display-file-info` that takes a file name and outputs a message displaying its type if known. ## Loops

@@ -78,6 +78,6 @@ ) try

) map 1 (+) reduce -This program calculates the size in bytes of all files included in the current directory. Because the {#link-operator||fs||fsize#} symbol throws an error if the argument provided is not a file (for example if it is a directory), the `try` symbol is used to remove the error from the stack and push `0` on the stack instead. +This program calculates the size in bytes of all files included in the current directory. Because the {#link-operator||fs||fsize#} symbol throws an error if the argument provided is not a file (for example, if it is a directory), the `try` symbol is used to remove the error from the stack and push `0` on the stack instead. {#link-learn||shell||Shell#}
M site/contents/learn-data-types.mdsite/contents/learn-data-types.md

@@ -10,13 +10,13 @@

boolean : **true** or **false**. integer -: A 64-bit integer number like 1, 27 or -15. +: A 64-bit integer number like 1, 27, or -15. float : A 64-bit floating-point number like 3.14 or -56.9876. string : A series of characters wrapped in double quotes: "Hello, World!". quotation -: A list of elements, which may also contain symbols. Quotations can be 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 + \*) +: 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 + \*) dictionary : 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 are symbols and therefore can only contain characters allowed in symbols. The {#link-module||dict#} provides some operators on dictionaries.

@@ -31,7 +31,7 @@ > "concatenative" :paradigm

> 2017 :first-release-year > } -The {#link-module||logic#} provides predicate operators to check if an element belong to a particular data type or pseudo-type (`boolean?`, `number?`, `integer?`, `float?`, `string?`, `quotation?`, `dictionary?`). +The {#link-module||logic#} provides predicate operators to check if an element belongs to a particular data type or pseudo-type (`boolean?`, `number?`, `integer?`, `float?`, `string?`, `quotation?`, `dictionary?`). Additionally, the {#link-module||lang#} provides operators to convert values from a data type to another (e.g. {#link-operator||lang||int#}, {#link-operator||lang||string#}, and so on).
M site/contents/learn-definitions.mdsite/contents/learn-definitions.md

@@ -45,7 +45,7 @@ ) dequote

...What is the value of the symbol `a` after executing it? -Simple: `4`. Every quotation defines its own scope, and in each scope a new variable called `a` is defined. In the innermost scope containing the quotation `(a dup * :a)` the value of `a` is set to `64`, but this value is not propagated to the outer scopes. Note also that the value of `a` in the innermost scope is first retrieved from the outer scope (8). +Simple: `4`. Every quotation defines its own scope, and in each scope, a new variable called `a` is defined. In the innermost scope containing the quotation `(a dup * :a)` the value of `a` is set to `64`, but this value is not propagated to the outer scopes. Note also that the value of `a` in the innermost scope is first retrieved from the outer scope (8). If we want to change the value of the original `a` symbol defined in the outermost scope, we have to use the {#link-operator||lang||bind#} or its shorthand sigil `@`, so that the program becomes the following:

@@ -74,9 +74,9 @@ - expected: {top} quot quot {bottom}

- got: {top} quot int {bottom} <repl>(1,19) in symbol: map -This error says that when the {#link-operator||lang||map#} operator was evaluated, there were incorrect values on the stack. Two quotations were expected, but instead a quotation and an integer were found. How did this happen? +This error says that when the {#link-operator||lang||map#} operator was evaluated, there were incorrect values on the stack. Two quotations were expected, but instead, a quotation and an integer were found. How did this happen? -Basically, when `my-list` was pushed on the stack, it pushed all its item on top of the stack. If you run {#link-operator||stack||get-stack#}, it will return the following list: +Basically, when `my-list` was pushed on the stack, it pushed all its items on top of the stack. If you run {#link-operator||stack||get-stack#}, it will return the following list: (1 2 3 4 5 (dup *))
M site/contents/learn-scopes.mdsite/contents/learn-scopes.md

@@ -4,8 +4,8 @@ title: "Scopes"

----- {@ _defs_.md || 0 @} -As explained in [Definitions](/learn-definitions), min uses lexical scoping to resolve symbol. A *scope* is an execution context (a symbol table really) that: -* is created while a a new quotation is being dequoted or a dictiionary is created. +As explained in [Definitions](/learn-definitions), min uses lexical scoping to resolve symbols. A *scope* is an execution context (a symbol table really) that: +* is created while a new quotation is being dequoted or a dictionary is created. * is destroyed after a quotation has been dequoted. * is attached to a dictionary.

@@ -55,6 +55,6 @@ In this case, when `with` is pushed on the stack, it will dequote `(4 2 minus)`. Note that the symbol `minus` is defined in the dictionary that will be used by `with` as the current scope, so after `with` is pushed on the stack, the stack contents are:

4 2 (-) -At this points, the {#link-operator||lang||dequote#} operator is pushed on the stack and the subtraction is executed leaving `2` on the stack. +At this point, the {#link-operator||lang||dequote#} operator is pushed on the stack and the subtraction is executed leaving `2` on the stack. {#link-learn||control-flow||Control Flow#}
M site/contents/learn-shell.mdsite/contents/learn-shell.md

@@ -10,7 +10,7 @@ > %min-terminal%

> [$](class:prompt) min -i > <span class="prompt">&#91;/Users/h3rald/Development/min&#93;$</span> -Although not as advanced, the min REPL is not dissimilar from an OS system shell like Bash, and as a matter of fact it provides many functionalities that are found in other shells or command prompts, such as: +Although not as advanced, the min REPL is not dissimilar from an OS system shell like Bash, and as a matter of fact, it provides many functionalities that are found in other shells or command prompts, such as: * Auto-completion * Persistent line history
M site/contents/learn.mdsite/contents/learn.md

@@ -19,17 +19,17 @@ (1 4 9 16 25)

Let's see how it works: -1. First a list containing the first five integer is pushed on the stack. -2. Then, another list containing two symbols (`dup` and `*`) is pushed on the stack. This constitutes a quoted program which, when executed duplicates the first element on the stack &mdash;this is done by `dup`&mdash; and then multiplies &mdash;with `*`&mdash; the two elements together. +1. First, a list containing the first five integers is pushed on the stack. +2. Then, another list containing two symbols (`dup` and `*`) is pushed on the stack. This constitutes a quoted program which, when executed duplicates the first element on the stack &mdash; this is done by `dup`&mdash; and then multiplies &mdash; with `*`&mdash; the two elements together. 3. Finally, the symbol `map` is pushed on the stack. Map takes a list of elements and a quoted program and applies the program to each element. Note that: * There are no variable assignments. * elements are pushed on the stack one by one. -* Parentheses are used to group together one or more elements, so that they are treated as a single element and they are not evaluated immediately. +* Parentheses are used to group one or more elements together so that they are treated as a single element and they are not evaluated immediately. * *Symbols* (typically single words, or several words joined by dashes) are used to execute code that performs operations on the whole stack. -Unlike more traditional programming languages, in a concatenative programming language there is no inherent need of variables or named parameters, as symbols acts as stack operators that consume elements that are placed in order on top of a stack. +Unlike more traditional programming languages, in a concatenative programming language, there is no inherent need for variables or named parameters, as symbols act as stack operators that consume elements that are placed in order on top of a stack. {#link-learn||data-types||Data Types#}