refresh a few examples in the docs

This commit is contained in:
Ava Apples Affine 2023-05-16 11:28:50 -07:00
parent 9febeabdb2
commit 69216db72a

View file

@ -20,8 +20,7 @@ The purpose of Relish is to create a highly portable, easy to integrate language
- Create UI bindings
* Contact
- Matrix chat: #relish:matrix.sunnypup.io
https://matrix.to/#/#relish:matrix.sunnypup.io
[[https://matrix.to/#/#relish:matrix.sunnypup.io][Matrix chat: #relish:matrix.sunnypup.io]]
* How to use
** Syntax
@ -133,9 +132,9 @@ If all forms evaluate to ~true~, ~true~ is returned.
Example:
#+BEGIN_SRC lisp
(circuit
(eq? (exit-code my-shell-command) 0)
(load my-shell-command) ;; exit 0 casted to true, also: requires CFG_RELISH_POSIX
(get-state-flag global-state)
(eq? (some-big-calculation) result))
(eq? (some-big-calculation) expected-result))
#+END_SRC
**** Not quite control flow
@ -220,12 +219,12 @@ Here is an example of an inline lambda call:
#+BEGIN_SRC lisp
((lambda (x y) (add x y)) 1 2)
#+END_SRC
This call returns ~3~.
This form (call) evaluates to (returns) ~3~.
Here is the lambda bound to a variable inside a let statement:
#+BEGIN_SRC lisp
(let ((adder (lambda (x y) (add x y)))) ;; let form contains one local var
(adder 1 2)) ;; local var (lambda) called here
(adder 1 2)) ;; local var (the lambda 'adder') called here
#+END_SRC
*** Defining variables and functions
@ -254,7 +253,7 @@ Make sure to read the *Configuration* section for information on how symbols are
**** Naming conventions
- Symbol names are case sensitive
- Symbols may contain alphanumeric characters
- Symbols may contain one or more of the following: - _ ?
- Symbols may contain one or more of the following: ~- _ ?~
- The idiomatic way to name symbols is ~all-single-case-and-hyphenated~
**** Undefining variables and functions
@ -298,7 +297,7 @@ args: x y
form: ((add x y))
#+END_EXAMPLE
#+BEGIN_EXAMPLE
> (help CFG_RELISH_ENV) <
> (help CFG_RELISH_ENV)
NAME: CFG_RELISH_ENV
ARGS: (its a variable)
@ -366,7 +365,7 @@ Translated, can be seen below
#+BEGIN_SRC lisp
(if (set? myvar)
() ;; no need to do anything... or add a call here
(def myvar "MY_SPECIAL_VALUE"))
(def myvar "my variable explanation..." "MY_SPECIAL_VALUE"))
#+END_SRC
Alternatively this combination can be used to process flags in a script or application:
@ -380,11 +379,13 @@ Alternatively this combination can be used to process flags in a script or appli
** Configuration
By default Relish will read from ~/.relishrc for configuration, but the default shell will also accept a filename from the RELISH_CFG_FILE environment variable.
See file:snippets/basic_minimal_configuration.rls for an example of a basic minimal configuration file.
Other snippets, including mood-prompt and avas-laptop-prompt demonstrate more complex configurations.
*** The configuration file
The configuration file is a script containing arbitrary Relish code.
On start, any shell which leverages the configuration code in the config module (file:src/config.rs) will create a clean seperate context, including default configuration values, within which the standard library will be initialized.
The configuration file is evaluated and run as a standalone script and may include arbitrary executable code. Afterwards, configuration values found in the variable map will be used to configure the standard library function mappings that the shell will use.
The configuration file is evaluated and run as a standalone script and may include arbitrary executable code.
Afterwards, configuration values found in the variable map will be used to configure the standard library function mappings that the shell will use.
Errors during configuration are non-terminal. In such a case any defaults which have not been overwritten will remain present.
**** Important points to note
@ -401,7 +402,8 @@ Errors during configuration are non-terminal. In such a case any defaults which
- CFG_RELISH_PROMPT_DELIMITER (default '>'): a function that is called with no arguments to output the delimiter separating prompt from user input
*** Prompt design
For an example of prompt design see file:snippets/mood-prompt.rls
For an example of prompt design see file:snippets/mood-prompt.rls
For a more complex example see file:snippets/avas-laptop-prompt.rls
*** Further configuration
Further configuration can be done by loading scripts that contain more functions and data to evaluate.
@ -482,14 +484,14 @@ Note: this section will not show the status of each item unless you are viewing
Note: this section only tracks the state of incomplete TODO items. Having everything on here would be cluttered.
** TODO Pre-alpha tasks
- Shell module (see branch: fully-interactive-shell)
- Shell module (see branch: ~fully-interactive-shell~)
- be able to fg a bg process
- be able to list all background processes with j function
- Documentation!
- Dogfood this for quite some time
- env prints without using columns
- circuit should actually be (reduce (lambda (form state) (and state (bool form))) my-args)
- rename STL to SLL (standard list library)
- circuit should actually be ~(reduce (lambda (form state) (and state (bool form))) my-args)~
- error display must improve at all costs
- make presentation on relish
- lisp basics
- s expressions
@ -516,6 +518,7 @@ Note: this section only tracks the state of incomplete TODO items. Having everyt
- signal management
- job control (and process groups)
- ergonomics of control flow as shell command
- circuit as progn
- circuit -> pipe
- let -> call-with
- putting it all together