version 0.2

try, throw implemented
help screen updates
some code reorganisation
readme and doc updates
This commit is contained in:
2021-06-10 23:26:14 +02:00
parent b50e9ba128
commit f594437b61
7 changed files with 227 additions and 105 deletions

View File

@@ -1,6 +1,24 @@
## Command line options
|option|Description|
|:-|-|
|-h|Prints help|
|-b|Skips loadin of std lib|
|-c code|Runs given code|
|-f source_file ..|Executes code in files|
|-i|Runs REPL|
|-p|Prints profile info at the end|
|-v|Prints version string|
## REPL commands
|Command|Description|
|:-|-|
|!q, !quit|Quit REPL|
|!e, !env|Display environment|
|!x, !export|Exports command from this session. Asks for filename to save|
## Syntax and Special Forms
|Special Form|Argument Evaluations|Purpose|
|:-|-|-|
|`(if cond a b)`|`if` only evaluates its `cond` argument. If `cond` is truthy (non-zero), then `a` is evaluated. Otherwise, `b` is evaluated.|This special form is the main method of control flow.|
@@ -123,12 +141,17 @@
|`(inc n)`|Return n incremented by 1|`>>> (inc 5) => 6`|
|`(sleep time)`|Pauses execution for time interval of seconds||
|`(get-env var)`|Return environment variable var|`>>> (get-env "HOME") => "/Users/vaclavt"`|
|`(second l)`|Returns second element of list||
|`(third l)`|Returns third element of list||
|`(fourth l)`|Returns fourth element of list||
|`(fifth l)`|Returns fifth element of list||
|`(nth i l)`|Return i-th elemenet of list. First element has index 1||
|`(second list)`|Returns second element of list|`>>> (second '(1 2 3 4 5 6 7)) => 2`|
|`(third list)`|Returns third element of list|`>>> (third '(1 2 3 4 5 6 7)) => 3`|
|`(fourth list)`|Returns fourth element of list|`>>> (fourth '(1 2 3 4 5 6 7)) => 4`|
|`(fifth list)`|Returns fifth element of list|`>>> (fifth '(1 2 3 4 5 6 7)) => 5`|
|`(nth i list)`|Return i-th elemenet of list. First element has index 1|`>>> (nth 7 '(1 2 3 4 5 6 7)) => 7`|
|`( make-csv list)`|creates csv string from list of lists|(print (make-csv '(("r1c1" "r1c2") ("r2c1" "r2c2"))))
|`(sprintf ..)`||`>>> (sprintf "%s, %d, %.2f" (list "string" 1000 3.14)) => "string, 1000, 3.14"`|
|`(thread-create code..)`|Creates new thread, starts evalueating code and returns immediatelly thread id||
|`(thread-under-lock lockname code)`|Acquire lock with lockname and eval code. ilock currently is only allowd lockname||
|`(thread-sleep milisecons)`|Sleeps thread for given amount of miliseconds||
|`(threads-join)`|Wait for all running threads to finish||
|`(try block catch_block [finally_block])`|Evaluates block and if an exception is thrown, evaluates catch_block.Eventually in both cases evals finally_block. Return evaluated last expression from block if no exception or last expression from catch_block, if exception is thrown from block. Variable ml-exception in catch block is available with astring describing exception||
|`(throw-exception exp_desc)`|Throws an exception with exp_desc describing what happened ||
|`(xx ..)`|||