all repos — min @ 7ca6a32528f9bd54f3cc5a7c1baf8690948b2e07

A small but practical concatenative programming language.

Fixed typo
Agent of User git@agentofuser.com
Fri, 15 May 2020 21:11:38 -0400
commit

7ca6a32528f9bd54f3cc5a7c1baf8690948b2e07

parent

eabd888f8f61f895c4022ca2b836c8410530592d

1 files changed, 4 insertions(+), 4 deletions(-)

jump to
M site/contents/learn-definitions.mdsite/contents/learn-definitions.md

@@ -12,7 +12,7 @@ "\.zip$" match

swap fsize 1000000 > and swap mtime now 3600 - > -This program takes a single string corresponding to a file path and returns true if it's a .zip file bigger than 1MB that was modified in the last how. 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-operator||stack||dup#} and {#link-operator||stack||swap#} are used for. +This program takes a single string corresponding to a file path and returns true if it's a .zip file bigger than 1MB that was modified in the last hour. 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-operator||stack||dup#} and {#link-operator||stack||swap#} are used for. The good news is that you can use the {#link-operator||lang||define#} operator and the `:` sigil to define new symbols, and symbols can also be set to literals of course.

@@ -47,7 +47,7 @@ ...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). -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 programs becomes the following: +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: 4 :a ;First definition of the symbol a (

@@ -92,12 +92,12 @@ my-list (dup *) map ;Returns (1 4 9 16 25)

## Sealing symbols -Finally, symbols can be sealed to pervent accidental updates or deletions. By default, all symbols defined in the core min modules are sealed, so the following code if run in min shell will result in an error: +Finally, symbols can be sealed to prevent accidental updates or deletions. By default, all symbols defined in the core min modules are sealed, so the following code if run in min shell will result in an error: 5 :quote -...because the symbol quote is already defned in the root scope. However, note that the folliwng code will _not_ return an error: +...because the symbol quote is already defined in the root scope. However, note that the following code will _not_ return an error: (5 :quote quote dup *) -> ;returns 25