diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2023-03-04 15:22:01 -0800 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2023-03-04 15:22:25 -0800 |
| commit | 2e9c68c309d004a38ab0c188c05f74291952e465 (patch) | |
| tree | a29ef2e1cd60252f18be094e15bea12446b8927a | |
| parent | 4ee93b3ff4b7a2d41a1d94f5a8ee769377bc7e34 (diff) | |
updated docs
| -rw-r--r-- | doc/precedent.1 | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/doc/precedent.1 b/doc/precedent.1 index a9c64e2..6f04f12 100644 --- a/doc/precedent.1 +++ b/doc/precedent.1 @@ -7,7 +7,7 @@ precedent \- simple interpreted language .SH DESCRIPTION Precedent is an interpreted language. The syntax is extremely simple, -which lends to a writing in a functional paradigm. However, precedent also +which lends to writing in a functional paradigm. However, precedent also supports imperative programming, with variable scoping and side-effects. Precedent supports integers, floats, and strings, with basic functions to manipulate each. Precedent has a simple pre-processor supporting @@ -43,17 +43,17 @@ literals or key references. The following are examples of key references with ar [ print("hello world"), print(myVar), print(eq(1, 2)) ]. Literals and keys may be separated by commas, semicolons, or spaces, to taste. .SH DETAILS +When a function defined by ref() is called as, e.g., myFunc(1, 1), its arguments (in this case, 1 and 1) are passed to the called function as arg0 and arg1. This implementation is subject to change. Logical functions treat all non-zero integer values as TRUE, and 0 as FALSE. Passing a float or a string to such a function will usually result in an error. Some logical functions short-circuit, meaning that they will cease evaluation as soon as their condition can no longer be met. For example, if the first argument to all() is FALSE, it will not evaluate the rest of its arguments. .SH FUNCTIONS -\fBroot() OR ()\fP -\-\- Executes all arguments. Returns the evaluation of the last symbol. Used to define a function. +\fBDATA STORAGE AND RETRIEVAL\fP \fBref()\fP \-\- Returns a pointer to its first argument, not evaluating it. \fBeval()\fP -\-\- Evaluates its first argument, passing the the rest of its arguments as argFALSE, argTRUE... etc. Essentially undoes ref(). +\-\- Evaluates its first argument, passing the the rest of its arguments as arg0, arg1... etc. Essentially undoes ref(). \fBstore()\fP \-\- Stores the evaluation of its first argument under the name specified by the (string) evaluation of its second argument. Use with ref() to store functions, or without to store variables. @@ -61,6 +61,8 @@ Logical functions treat all non-zero integer values as TRUE, and 0 as FALSE. Pas \fBupdate()\fP \-\- Stores the evaluation of its first argument under the name specified by the (string) evaluation of its second argument, in the same manner as store(). Update() differs from store when the key is not found in the local scope. In this case, update() searches upwards for the first scope containing the key, and overwrites its value. +\fBBOOLEAN LOGIC\fP + \fBeq()\fP \-\- Evaluates all of its arguments. If they are all equivalent, returns TRUE. Otherwise, returns FALSE. Can accept ints, floats, or strings. Strings cannot be mixed with floats or ints. @@ -76,18 +78,27 @@ Logical functions treat all non-zero integer values as TRUE, and 0 as FALSE. Pas \fBnone()\fP \-\- Evaluates all of its arguments. If none are TRUE, returns TRUE. Otherwise, returns FALSE. Short-circuits. +\fBCONTROL FLOW\fP + +\fBroot() OR ()\fP +\-\- Executes all arguments. Returns the evaluation of the last symbol. Used to define a function. + \fBif()\fP \-\- If its first argument is TRUE, evaluates the rest of its arguments. \fBwhile()\fP \-\- If its first argument is TRUE, evaluates the rest of its arguments. Then, if its first argument is still TRUE, evaluates the rest of its arguments again. Repeats until its first argument is FALSE. +\fBARITHMETIC\fP + \fBsum()\fP \-\- Evaluates all its arguments and returns the sum. If any argument is a float, returns a float. Otherwise, returns an int. \fBsub()\fP \-\- Evaluates all its arguments. Subtracts every argument after the first from the first. Returns the result, which is a float if any arguments were floats, or an int if all arguments were ints. +\fBI/O\fP + \fBprint()\fP \-\- Evaluates its arguments and writes to the terminal. Writes a newline after all its arguments. |
