x-lang

← Index

x/type/convert

Generic type conversion: the Convert class over the type system’s from/to alists.

Hot consumers fetch the dispatcher from the catalog: (prim-ref ‘convert ‘to). The no-match policy is the (Convert missing) member.

Class Convert

missing

No-match policy handler (fn (_ val target)). The dialect sets it – raise, coerce, log, … Default returns nil.

Member: data carried by a Convert instance.

(Convert to val target . extra)

Convert VAL to the TARGET type via the type system’s registered conversions.

Parameters:

Returns: ANY — The converted value; on no registered conversion, (Convert missing)’s result (default nil)

(Convert to-int v what)

V as an INT: V itself when it is one, else its registered conversion to INT; raises WHAT when there is none.

Parameters:

Returns: INT — The integer