Skip to main content

Module ops

Module ops 

Source
Expand description

Structural operations on values: equality, hashing, ordering, formatting, and arbitrary-precision integer arithmetic.

Operations that may need user code (==, hash, <=>, to_s defined on a class) go through the Interop trait, which the VM implements. Implementations never hold a borrow of an object’s contents across such a call; they re-read by index instead.

Structs§

Syms

Statics§

SYMS

Traits§

Interop
Calls back into the VM for operations defined in Catallaxy code.

Functions§

compare
<=>-style comparison. Returns None if the values are not comparable.
compare_or_panic
Compares or panics with a clear message.
dict_lookup
Finds key in a dict or set, returning its entry index.
dict_lookup_hashed
float_to_int
Truncates a float toward zero into an Int (panics on NaN/infinity).
format_float
Formats a float the way Catallaxy prints it: always with a decimal point or exponent.
format_int
hash_bytes
hash_int
hash_value
Hash consistent with values_eq.
inspect
inspect: strings print quoted.
int_add
int_as_i64
The value as i64 if it is an Int that fits.
int_bitop
int_cmp
int_div
Floor division (rounds toward negative infinity).
int_mod
Floor modulo: the result has the sign of the divisor.
int_mul
int_neg
int_pow
int_sub
int_to_f64
is_int
quote_str
Writes s as a quoted string literal.
sign_of
to_bigint
to_s
to_s: strings print raw, everything else as inspect.
values_eq
==: structural for builtins, enums and tuples; user == for classes defining it; identity otherwise. Int == Float compares numerically.