diff --git a/common-operation-script/ellipse-dev-language/errors.md b/common-operation-script/ellipse-dev-language/errors.md index c02ab26..5704fa1 100644 --- a/common-operation-script/ellipse-dev-language/errors.md +++ b/common-operation-script/ellipse-dev-language/errors.md @@ -80,3 +80,10 @@ To log an error and let it continue, call `(rethrow)` in the handler. `rethrow` `with-cleanup` runs cleanup forms when its body ends, also when the body raises an error. It is the `finally` of other languages. See [with-cleanup](language-guide.md#with-cleanup). `ignore-errors` returns `()` for any error. It hides mistakes, so use `handler-bind` with named conditions where you can. + +`try` (elps v1.99.0, substrate v2.261.0 and later) evaluates its forms in order and returns the value of the first form that does not raise an error. The last form is not protected: its error propagates. Use it for a fallback, such as a default when a conversion fails. It catches every error except the ones that stop an evaluation: a step limit, a cancellation and an internal panic. See [try](function-reference.md#try). Keep the protected forms small, so that `try` does not hide a mistake. Inside a `defflow`, `try` may not contain an await. + +```lisp +(list (try (to-int "12") 0) + (try (to-int "abc") 0)) ; evaluates to '(12 0) +``` diff --git a/common-operation-script/ellipse-dev-language/function-reference.md b/common-operation-script/ellipse-dev-language/function-reference.md index c9cd52a..0148b86 100644 --- a/common-operation-script/ellipse-dev-language/function-reference.md +++ b/common-operation-script/ellipse-dev-language/function-reference.md @@ -1,12 +1,12 @@ --- -description: Every ELPS builtin, macro and library function in elps v1.98.0, from its docstring. +description: Every ELPS builtin, macro and library function in elps v1.100.0, from its docstring. --- # Function Reference - + -This page lists every function, macro, special operator and variable of ELPS v1.98.0, the release the examples on this site run. It is generated from the docstrings in [luthersystems/elps](https://github.com/luthersystems/elps/tree/v1.98.0), the same text `elps doc ` prints. For examples and guidance, see the [Standard Library](standard-library.md) and the [Language Guide](language-guide.md). +This page lists every function, macro, special operator and variable of ELPS v1.100.0, the release the examples on this site run. It is generated from the docstrings in [luthersystems/elps](https://github.com/luthersystems/elps/tree/v1.100.0), the same text `elps doc ` prints. For examples and guidance, see the [Standard Library](standard-library.md) and the [Language Guide](language-guide.md). Functions of the `lisp` package need no prefix. Call a function of another package with its package name, such as `string:join`. @@ -54,7 +54,7 @@ Paths are given as positional ELPS values — one argument per path step, no str list array slice '(range 1 3), '(range 1) ``` -? reads without copying. ?set, ?del and ?nil copy the document's maps, lists and vectors; their "!" forms mutate in place. In-place edits of list elements are refused; use a copying form or a vector instead. An out-of-range integer index leaves the document unchanged on a write (and returns nil on a read). Negative indexes count from the end. +? reads without copying. ?? reads as ? does, but returns nil when a step meets nil. ?set, ?del and ?nil copy the document's maps, lists and vectors; their "!" forms mutate in place. In-place edits of list elements are refused; use a copying form or a vector instead. An out-of-range integer index leaves the document unchanged on a write (and returns nil on a read). Negative indexes count from the end. Tagged values and quote wrappers are rebuilt recursively by copying writes and traversed by cycle checks, but cannot be indexed into. Other value types are opaque leaves, including symbols, bytes, functions and natives. Reads may return them and writes may store them. A further path step into a leaf raises an error naming its type and location. Copies share opaque leaves by reference; mutation of their storage outside elpspath is visible through both documents. Writes need containers that are acyclic and arrays with exactly one dimension, and check this throughout the document, including off-path containers and the contents of tagged values and quote wrappers, because a write may copy or rebuild any of them. New values pass the same check. A read (?) with a path checks only what that path steps into: it never walks beyond its path or into the value it returns, so a fault elsewhere cannot change its answer, and its cost follows the path rather than the document. A read with no path checks the whole document, as writes do. Function bodies and captured environments remain opaque and shared; they are not walked. @@ -84,6 +84,18 @@ Values of any leaf type may be read. Descending into a leaf raises an error nami Accepts at most 1024 nested iterator steps; deeper traversal raises a depth error. +### `elpspath:??` + +*function*: `(elpspath:?? val &rest steps)` + +Get value at a path, returning nil when a step meets nil. + +The same as ?, except that a step into nil returns nil instead of raising an error. So a missing key, an out-of-range index or a stored () anywhere on the path gives nil. A step into a leaf of the wrong type, such as a number or a string, still raises an error, because that is a fault in the data or the path. + +(?? obj "foo" 0 "bar") => nil when obj has no "foo" (? obj "foo" 0 "bar") => error: first argument is nil (?? obj "foo" 0) => error when obj's "foo" is a number (?? obj) => obj itself (no path steps) + +After a '\* step, ? already gives nil for each element whose path fails, so ?? reads the same as ? from there. + ### `elpspath:?del` *function*: `(elpspath:?del val &rest steps)` @@ -1179,7 +1191,7 @@ Returns true if expr is a sorted-map, false otherwise. *function*: `(stable-sort less-predicate list &rest key-fun)` -Sorts list using the binary less-predicate and returns the sorted list. The sort is stable. An optional key-fun extracts comparison keys from elements. Both callbacks must be regular functions; elements and keys are passed as data without evaluation. A mutable list is sorted in place, so sorting a slice view also sorts that region of its source; sort (concat 'list x) when x is a view you do not own. A quoted program literal is never modified: sorting a non-empty literal (or a view sharing its storage) raises the catchable modify-literal-error condition -- sort (copy lit) instead. +Sorts list using the binary less-predicate and returns the sorted list. The sort is stable. An optional key-fun extracts comparison keys from elements. key-fun runs once per element, in list order, before any comparison, and does not run for a list of fewer than two elements. Both callbacks must be regular functions; elements and keys are passed as data without evaluation. A mutable list is sorted in place, so sorting a slice view also sorts that region of its source; sort (concat 'list x) when x is a view you do not own. A quoted program literal is never modified: sorting a non-empty literal (or a view sharing its storage) raises the catchable modify-literal-error condition -- sort (copy lit) instead. ### `string<` @@ -1301,6 +1313,12 @@ Evaluates expr, prints the result to stderr prefixed by message (default "TRACE" Returns true if expr is truthy (not nil and not false), false otherwise. Useful as an explicit boolean conversion. +### `try` + +*operator*: `(try &rest exprs)` + +Evaluates exprs in order and returns the value of the first one that does not signal an error. When an expr signals, its error is dropped and the next expr is evaluated. The last expr is not guarded: its value is returned and its error propagates, so a program can give a default value or raise its own error last. (try x) is x, and (try) returns (). A result of () or false is a success, unlike (or (ignore-errors x) y). The conditions that stop an evaluation are never caught and always propagate: internal-panic (a Go panic recovered from host code), step-limit-exceeded, step-budget-exceeded and context-cancelled. A fallback must not turn a stop into a value. Side effects of an expr that signals are not undone. Like ignore-errors, blocks tail-call optimization across this form. + ### `type` *function*: `(type value)` diff --git a/common-operation-script/substrate/defflow.md b/common-operation-script/substrate/defflow.md index 5e3fb85..72d576d 100644 --- a/common-operation-script/substrate/defflow.md +++ b/common-operation-script/substrate/defflow.md @@ -149,7 +149,7 @@ A run is in one of three states: `waiting`, `done` or `failed`. ([Destructuring in let](../ellipse-dev-language/let-destructuring.md)), `match` ([Pattern Matching](../ellipse-dev-language/pattern-matching.md)), `handler-bind`, `ignore-errors`, `flet` and `labels` work across awaits. An -await inside `dotimes`, `with-cleanup` or a `lambda` (other than an inline +await inside `dotimes`, `with-cleanup`, `try` (substrate v2.261.0 and later) or a `lambda` (other than an inline `:on-error` handler) is a compile error. Use `while` for a loop that awaits. diff --git a/release-notes.md b/release-notes.md index fa80de9..b6e114d 100644 --- a/release-notes.md +++ b/release-notes.md @@ -22,6 +22,118 @@ Issues.

Operator settings applied to the chaincode container are catalogued in [Chaincode Environment Variables](common-operation-script/substrate/chaincode-environment-variables.md). +## 2026-12-04: elps v1.105.0 + +- **Language**: In a host that shares loaded code between requests, such as substrate, binding a new name or docstring in a loaded package no longer copies the whole package for that request. Only an `export` still does. Code that binds new names at run time, such as a nested `defun`, costs much less +- **Tooling**: New lint check `nested-defun` reports a `defun`, `defmacro` or `deftype` inside a function body. Such a definition rebinds a package global each time the outer function runs, and every call shares it. Move it to the top level, or bind a `lambda` in a `let` for a local function +- **Tooling**: Source analysis, `elps lint` and the language server see the forms in a bracketed `cond` clause, such as `[(> x 0) 'pos]`, and in a bracketed `handler-bind` binding list. Before, they skipped those forms, so a lint check or a go-to-definition missed what was inside + +Details: [elps v1.105.0 release](https://github.com/luthersystems/elps/releases/tag/v1.105.0). + +## 2026-12-04: elps v1.104.0 + +- **Language**: The math functions that round (`exp`, `ln`, `log`, the trigonometric and hyperbolic functions and their inverses), and `pow` with a fractional exponent, give the same bits on every CPU: the bits Go 1.27 gives on arm64. On arm64 no result changes. On amd64 some results change, most in the last bit. Machines that must agree, such as endorsing peers of one channel, need a coordinated upgrade only where some of them are not arm64 +- **Language**: `ignore-errors` lets stop conditions through, such as a step limit or a cancelled request, so it no longer hides them +- **Language**: libschema fixes: `s:gt`, `s:gte`, `s:lt` and `s:lte` compare int bounds exactly, also past 2^53. A nested `s:has-key` inside `s:of`, `s:has-key` or `s:may-have-key` passes a valid value; before, it refused every value. Six combinators return an error that is not a type failure, such as a `:check` that raises its own condition, instead of reporting it as one. A validation that applies more than 1,048,576 constraints in one call charges a step for each constraint past that +- **Language**: A template VM caches each package lookup at its call site, so calls to package functions take less time + +Details: [elps v1.104.0 release](https://github.com/luthersystems/elps/releases/tag/v1.104.0). + +## 2026-11-24: substrate v2.262.0 + +- **substrate**: **Upgrade note:** this release changes results and step counts that a phylum can see. Upgrade every peer and pre-deploy checker of a channel together, at the same time. A channel with peers on mixed versions can split endorsements. No setting turns the changes off. See the [upgrade notes](https://github.com/luthersystems/substrate/blob/v2.262.0/docs/substrate-api.md) +- **substrate**: **Breaking:** `cc:bptree-open` refuses a non-nil `:compare`, and so does a storage object's `'bptree-open` with a non-nil comparator. Every B+-tree is in byte-wise string order. Before you upgrade, copy each tree that uses a comparator to a new prefix opened without one, with keys encoded so their bytes sort in the order you need, and let any saved defflow run that holds such a tree finish. `shirotester lint` reports each such call (`bptree-compare`) +- **substrate**: Security: a `cc-fetchurl` request through an env proxy exempts only that hop from the destination guard. Before, a later direct request or redirect to the proxy's host and port also skipped the guard +- **substrate**: The chaincode bundles elps v1.103.0 (from v1.100.0). `equal?` is reflexive for functions, errors and native values, so a value is `equal?` to itself. This reaches `utils:deep-equal?`, the validation equality checks, `match` patterns and schema const and enum checks +- **substrate**: An `elpspath` range replacement may be the empty list, which deletes the range. An empty range window on a list, such as `(elpspath:? '(1 2 3) '(range 1 1))`, returns `()`. Both used to raise an error +- **substrate**: The mutating path writes (`set-path!`, `del-path!`, `nil-path!`, `elpspath:?set!`, `?del!`, `?nil!` and the `utils` helpers that call them) check only what their path steps into, so each write costs the same on a small or a large document. A fault in the document off the write's path no longer fails the write. The copying writes still check the whole document, and the value that `set-path!` stores is still checked in full +- **substrate**: The step charge of `get-path`, `set-path!`, `set-path`, `del-path!`, `del-path`, `nil-path!` and `nil-path` with an iterator (`[]`) counts the values the path really reaches. Most such charges go down, often by a lot. After an iterator, a negative range end or an empty window makes the next step cost one step for each window, where it cost one step in all. Results do not change. Under a step limit (`SUBSTRATE_ELPS_MAX_STEPS`, or defflow's step limit for a flow transaction) a call can now pass or fail at a different step. The charge now uses memory that follows the path length, so a cyclic or widely shared document no longer runs the chaincode out of memory. On a cyclic value the charge can still run until a step limit or a request timeout stops it, so set `SUBSTRATE_ELPS_MAX_STEPS` +- **substrate**: `cc:parse-timestamp-unix` and `cc:parse-timestamp-unix-reverse` return UTC, and `cc:parse-timestamp` keeps the offset in its text. Date arithmetic on a parsed timestamp gives the same result on peers in different host time zones +- **substrate**: `cc:csprng-generate` fails, and reads no entropy, when the size is more than the remaining entropy or above the VM's allocation limit +- **substrate**: `base32:decode` of bytes returns only the decoded bytes. Before, it returned extra NUL bytes when the input had `=` padding or line breaks, so a phylum that stored such a result now stores different bytes +- **substrate**: defflow refuses a flow context held in a record field across an await, with `flow-unsavable`, as it does for a context in a list or map. Keep the context in a closure. A run saved before the upgrade still restores +- **substrate**: `s:no-other-keys` on a non-map input raises `wrong-type`, which a handler can catch. `s:bool` and `s:is-falsy` take no name from the `gensym` counter when they validate, so a later `gensym` in the same transaction can return a different name +- **substrate**: defflow compiles a run of awaits to linear code, so a phylum with many awaits loads faster. Some resume transactions take a few fewer steps +- **substrate**: The `mxf:encode` overlap check takes fewer steps when many transforms share a path. This step change and the defflow one matter only under a step limit; then upgrade peers together. `mxf:encode`, `mxf:decode`, base58, transaction metadata and log fields no longer take quadratic time on large inputs +- **substrate**: The chaincode keeps fewer Go stack frames per Lisp call, so a transaction uses less CPU +- **substrate**: The WebAssembly SDK moves to elps v1.101.0. A module rebuilt against it refuses typed JSON whose object members are out of order, and each call costs fewer steps. A deployed module keeps the elps it was built with +- **Tooling**: `shirotester lint` gets the `macro-quoted-head` check, which reports a macro whose expansion returns data instead of code + +Details: [substrate v2.262.0 release](https://github.com/luthersystems/substrate/releases/tag/v2.262.0). + +## 2026-11-23: elps v1.103.0 + +- **Language**: An empty range window on a list in an `elpspath` read, such as `(elpspath:? '(1 2 3) '(range 1 1))`, returns `()`. Before, it raised an error. The same window on a vector already returned an empty vector +- **Language**: New Go function `libelpspath.Visit` walks a path and counts the values each step reaches, with the same rules as a path read. An embedder can use it to charge for a path operation + +Details: [elps v1.103.0 release](https://github.com/luthersystems/elps/releases/tag/v1.103.0). + +## 2026-11-22: elps v1.102.0 + +- **Language**: The mutating `elpspath` writes (`?set!`, `?del!`, `?nil!`) check only what their path steps into. A fault in the document off the write's path no longer fails the write, and a write costs the same on a small or a large document. The value that `?set!` stores is still checked in full, and the copying writes still check the whole document +- **Language**: A deep `let*` of closures takes linear memory, and an `export` of many names, many names bound to one function, and long chains of tail calls take linear time + +Details: [elps v1.102.0 release](https://github.com/luthersystems/elps/releases/tag/v1.102.0). + +## 2026-11-21: elps v1.101.0 + +- **Language**: `equal?` is reflexive for functions, errors and native values. A value is `equal?` to itself, and two functions are `equal?` when they hold the same function +- **Language**: An `elpspath` range replacement may be the empty list, which deletes the range, as an empty vector did +- **Language**: The evaluator keeps fewer Go stack frames per Lisp call, so deep calls use less CPU and memory +- **Tooling**: New lint check `macro-quoted-head` reports a macro whose expansion has a quoted symbol at its head, so it returns data instead of code + +Details: [elps v1.101.0 release](https://github.com/luthersystems/elps/releases/tag/v1.101.0). + +## 2026-11-20: elps v1.100.2 + +- **Language**: `s:no-other-keys` on a non-map input raises `wrong-type`, which a handler can catch +- **Language**: `s:bool` and `s:is-falsy` build their inner validators once, so a validation takes no name from the `gensym` counter +- **Language**: A function with up to 16 `&key` formals binds them faster. `lval.Unmarshal` refuses object members out of order, as the typed JSON loader does +- **Tooling**: The minifier keeps `&key` formal names. The language server sends semantic tokens in the position encoding the client chose + +Details: [elps v1.100.2 release](https://github.com/luthersystems/elps/releases/tag/v1.100.2). + +## 2026-11-19: elps v1.100.1 + +- **Language**: `lval.Unmarshal` checks strings and integers in the pass that reads them. It refuses the same input with the same errors, and costs fewer steps in a WebAssembly module + +Details: [elps v1.100.1 release](https://github.com/luthersystems/elps/releases/tag/v1.100.1). + +## 2026-11-19: substrate v2.261.0 + +- **substrate**: **Upgrade note:** this release changes results and step counts that a phylum can see. Upgrade every peer and pre-deploy checker of a channel together. No setting turns the changes off. See the [upgrade notes](https://github.com/luthersystems/substrate/blob/v2.261.0/docs/substrate-api.md) +- **substrate**: Bundles elps v1.100.0, with the new `try` special operator and `elpspath:??` (elps v1.99.0). defflow refuses an await, `done` or `fail` inside `try`. A phylum that defines its own `try` keeps it +- **substrate**: `stable-sort` with a key function takes fewer steps. A key function with a side effect, or one that returns a new value each call, can give a different order +- **substrate**: `bptree-range-limit-query` on a tree opened with `:compare` checks the range in the tree's order. A range reversed in that order returns no pairs, where before some failed with `invalid range` +- **substrate**: `cc:storage-content-fingerprint` keeps the hash's error: a step limit or a cancelled request signals `step-limit-exceeded` or `context-cancelled`, not `error` +- **substrate**: The WebAssembly SDK moves to elps v1.100.0. A module rebuilt against it refuses input that `lval.Marshal` does not write, and each call costs more steps (about 13% on a large input). A deployed module keeps the elps it was built with +- **Tooling**: In the VS Code extension and `shirotester lint`, a function that a workspace `def*` macro defines in another file is no longer reported as undefined + +Details: [substrate v2.261.0 release](https://github.com/luthersystems/substrate/releases/tag/v2.261.0). + +## 2026-11-19: elps v1.100.0 + +- **Language**: `lval.Unmarshal`, the Go reader for ELPS values that WebAssembly modules use, refuses the numbers, strings and tags that the typed JSON loader refuses: a bare `"~"`, a `"~n"` integer that fits a JSON number, non-canonical base64, numbers such as `01`, `-0`, `1.0` and `1e2`, and string escapes that `lval.Marshal` does not write. Before, it read them, and a value did not always write back as the same bytes + +Details: [elps v1.100.0 release](https://github.com/luthersystems/elps/releases/tag/v1.100.0). + +## 2026-11-19: elps v1.99.0 + +- **Language**: New special operator `try`. `(try a b c)` returns the value of the first form that does not raise an error. The last form is not protected. See [Errors](common-operation-script/ellipse-dev-language/errors.md) +- **Language**: New `elpspath:??`. It reads as `elpspath:?` does, but returns `()` when a step meets `()`, such as a missing key. A step into a number or a string is still an error +- **Language**: `stable-sort` calls its key function once per element, in list order. A sort with a key function takes fewer steps +- **Language**: `#^` counts only symbols such as `%1` as placeholders. Before, a string `"%1"` in the body also counted +- **Language**: `lval.Unmarshal` refuses the map keys that the typed JSON loader refuses +- **Tooling**: The language server, `elps lint` and `elps mcp` find a function that a workspace `def*` macro defines in another file. Before, they could report it as undefined + +Details: [elps v1.99.0 release](https://github.com/luthersystems/elps/releases/tag/v1.99.0). + +## 2026-11-15: substrate v2.260.0 + +- **shiroclient**: The gateway's usage reporting sends again the block ranges that an earlier report gave up on, when the license server asks for them. Each report sends at most 2,000 such blocks, oldest first; set `SHIROCLIENT_USAGE_BACKFILL_BLOCKS` to change the limit, or to `0` to turn it off. A failed resend never fails the report. The gateway counts resent blocks in `luther_license_usage_blocks_backfilled_total`. This changes only the gateway: transactions and endorsements are the same + +Details: [substrate v2.260.0 release](https://github.com/luthersystems/substrate/releases/tag/v2.260.0). + ## 2026-11-13: substrate v2.259.0 - **substrate**: **Upgrade note:** some transactions take fewer ELPS steps. If you set a step limit (`SUBSTRATE_ELPS_MAX_STEPS`), upgrade every peer and pre-deploy checker of a channel together. See the [upgrade notes](https://github.com/luthersystems/substrate/blob/v2.259.0/docs/substrate-api.md)