all repos — min @ 020c873cbe4ca7da941d97fbdb3f3322ac04882d

A small but practical concatenative programming language.

Documenting learning section.
h3rald h3rald@h3rald.com
Sun, 16 Jul 2017 19:44:12 +0200
commit

020c873cbe4ca7da941d97fbdb3f3322ac04882d

parent

b3059e9053474931e2524e9ac66a3d00d212a1e5

M site/assets/styles/min-lang.csssite/assets/styles/min-lang.css

@@ -77,7 +77,7 @@ text-align: center;

margin: auto; } -b, strong { +b, strong, dt { font-weight: 400; }
M site/contents/_includes/_defs_.mdsite/contents/_includes/_defs_.md

@@ -81,3 +81,15 @@ {# link-module => [`$1` Module](/reference-$1/) #}

{# link-operator => [`$2`](/reference-$1/$2) #} +{# link-learn => → Continue to [*$2*](/learn-$1) #} + +{{ learn-links => +> %sidebar% +> Quick Links +> +> * [Data Types](/learn-data-types) +> * [Operators](/learn-operators) +> * [Quotations](/learn-quotations) +> * [Variables](/learn-variables) +> * [Shell](/learn-shell) +}}
M site/contents/_includes/_learn-data-types.mdsite/contents/_includes/_learn-data-types.md

@@ -1,5 +1,34 @@

------ -content-type: page -title: Learn ------ -Coming soon... +{@ _defs_.md || 0 @} + +The type system of min is very simple -- only the following data types are available: + +integer +: An integer number like 1, 27 or -15. +float +: A 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). + +Additionally, quotations structured in a particular way can be used as dictionaries, and a few operators are available to manage them more easily (`dhas?`, `dget`, `ddel` and `dset`). A dictionary is a quotation containing zero or more quotations of two elements, the first of which is a symbol that has not already be used in any of the other inner quotations. + +> %sidebar% +> Example +> +> The following is a simple dictionary containing three keys: *name*, *paradigm*, and *first-release-year*: +> +> ( +> (name "min") +> (paradigm "concatenative") +> (first-release-year 2017) +> ) + +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?`). + +> %note% +> Note +> +> Most of the operators defined in the {#link-module||num#} are able to operate on both integers and floats. + +{#link-learn||operators||Operators#}
D site/contents/_includes/_learn-modules.md

@@ -1,5 +0,0 @@

------ -content-type: page -title: Learn ------ -Coming soon...
M site/contents/_includes/_learn-operators.mdsite/contents/_includes/_learn-operators.md

@@ -1,5 +1,2 @@

------ -content-type: page -title: Learn ------ +{@ _defs_.md || 0 @} Coming soon...
M site/contents/_includes/_learn-quotations.mdsite/contents/_includes/_learn-quotations.md

@@ -1,5 +1,2 @@

------ -content-type: page -title: Learn ------ +{@ _defs_.md || 0 @} Coming soon...
M site/contents/_includes/_learn-shell.mdsite/contents/_includes/_learn-shell.md

@@ -1,5 +1,2 @@

------ -content-type: page -title: Learn ------ +{@ _defs_.md || 0 @} Coming soon...
D site/contents/_includes/_learn-syntax.md

@@ -1,5 +0,0 @@

------ -content-type: page -title: Learn ------ -Coming soon...
M site/contents/_includes/_learn-variables.mdsite/contents/_includes/_learn-variables.md

@@ -1,5 +1,1 @@

------ -content-type: page -title: Learn ------ Coming soon...
M site/contents/_includes/_learn.mdsite/contents/_includes/_learn.md

@@ -1,3 +1,30 @@

-Coming soon. Really soon, I promise! +{@ _defs_.md || 0 @} + +{{learn-links}} + +*min* 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 min will look somewhat familiar to you. + +If not, well, here's how a short min program looks like: + + (1 2 3 4 5) (dup *) map + +This program returns a list containing the square values of the first five integer numbers: + + (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 (`dup`) the first element on the stack and then multiplies (`*`) 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 grouped together one or more elements, so that they are treated as a single element and they are not evaluated immediately. +* Symbols can be used to perform 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. -Well, OK, maybe a little while... but the [reference](/reference/) stuff is up-to-date! Have a look at that instead for now, and see if you can figure it out ;) +{#link-learn||data-types||Data Types#}
A site/contents/learn-data-types.md

@@ -0,0 +1,5 @@

+----- +content-type: "page" +title: "Learn: Data Types" +----- +{@ _includes/_learn-data-types.md || 0 @}
A site/contents/learn-operators.md

@@ -0,0 +1,5 @@

+----- +content-type: "page" +title: "Learn: Operators" +----- +{@ _includes/_learn-operators.md || 0 @}
A site/contents/learn-quotations.md

@@ -0,0 +1,5 @@

+----- +content-type: "page" +title: "Learn: Quotations" +----- +{@ _includes/_learn-quotations.md || 0 @}
A site/contents/learn-shell.md

@@ -0,0 +1,5 @@

+----- +content-type: "page" +title: "Learn: Shell" +----- +{@ _includes/_learn-shell.md || 0 @}
A site/contents/learn-variables.md

@@ -0,0 +1,5 @@

+----- +content-type: "page" +title: "Learn: Variables" +----- +{@ _includes/_learn-variables.md || 0 @}