Documentation/Reference

Callback-dependent failure contracts

On this page

A wrapper should admit the errors of the callback it receives. Declare FAILS LIKE action when action is a checked CALLABLE parameter. Chapter 11 shows a complete wrapper and handler. Passing an infallible callback makes that use infallible; passing a callback declaring SigningFailure contributes that error family. The wrapper must separately declare or handle any unrelated error of its own.

Stored callbacks and configuration

FAILS LIKE can follow callbacks stored in supported records, optionals, lists and dictionaries. Inferred construction retains those contracts; a list combines its elements’ admitted errors. An explicit wider annotation deliberately widens the checked value. Mutation must fit the storage type, including in loops. Writable references require matching contained contracts.

Copies, caught/rethrown errors and retained task outcomes preserve the checked set and concrete payload. A parent error view does not slice away descendant data. No generic InvocationError wrapper or hidden widening to Error is inserted. Broad-catch warnings describe declared error sets and call/callback origins; an open family is not an enumeration of every future descendant.

Returning values with the caller’s contract

AS LIKE formal returns an owned value with that formal’s representation and contained checked contracts. It is not a BORROW return or a lifetime extension. AS Wrapper LIKE formal carries the admitted invocation set into an owned wrapper shape. The body must satisfy that contract; ordinary explicit wide result types still widen it. Repeated positions sharing a callable shape conservatively use their admitted union.

Referring to a known operation

A signature reference such as FAILS LIKE Decode(AS STRING) uses an operation’s checked declaration without running it. Spell every parameter type, including BYREF AS Type or TAKE AS Type when required. An optional result annotation, such as LIKE Decode(AS STRING) AS Customer, can resolve result-only context. The reference needs a unique visible overload. Value expressions, omitted/default arguments and arbitrary runtime evaluation do not belong in a signature reference.

Cyclic or excessively deep dependencies are rejected. Taking a function with a dependent result as a first-class callable is currently restricted; use an ordinary checked call. C exports and plain C imports require their supported fixed contracts. Compatible BASIL libraries preserve these dependencies through their public interfaces, together with ordinary ownership and cleanup checks.

From the BASIL documentation. View source ↗

Find your way around BASIL

Type to search the manual.