Skip to main content

Module ops

Module ops 

Source
Expand description

The derived operations (design §3.7): structural eq, compare, and hash over Value + descriptor. show is the canonical JSON encoder (json::encode).

At the Soil level the derived functions are monomorphic per-type definitions (Foo::eq, Foo::compare — design §3.7’s chosen spelling); each of them lowers to a call into this one engine with its type’s descriptor (plan 01 scope item 5: “one implementation each over Value + descriptor”). Static exclusion of closures and per-type applicability live in the checker, which only elaborates T::eq at types that derive it; the DerivationErrors here are a defensive backstop behind that, not the primary enforcement. A compiler may later specialize per type; the semantics are fixed here.

eq is defined as compare == Equal, so the agreement laws hold by construction. hash is FNV-1a 64-bit over the value’s canonical JSON encoding — one byte-form of a value in the whole system — with the opaque strategy hashing the allocation address instead (resolved decisions, impl plan §1; recorded in design §3.7).

Functions§

compare
The derived total order.
eq
Structural equality: compare(a, b) == Equal. NaN equals NaN; -0.0 and 0.0 are distinct; ignored fields are skipped; opaque values and opaque-strategy types compare by allocation address.
hash
FNV-1a 64-bit over the value’s canonical JSON encoding; the opaque strategy (and opaque handles) hash the allocation address instead. Fixed and platform-independent: hash is language-observable.