Skip to content

sysl 0.12.0

Choose a tag to compare

@edadma edadma released this 20 Nov 22:34
· 210 commits to dev since this release

A minor release: every check now reports through one weak sysl_trap hook, references get a null niche in Option, trait objects can be downcast, build-c --shared builds a self-contained dynamic library, and the standard library gains big-integer arithmetic at scale, checksums, vector math and more. Some programs 0.11.15 accepted are now refused; they are listed first.

Install

brew install sysl-lang/tap/sysl

or download sysl-0.12.0-darwin-arm64.tar.gz below and put its bin/ on your PATH; the compiler finds share/sysl/library beside itself.

Behaviour changes

  • Every failure reports through sysl_trap. Every compiler-inserted check (contracts, within/where, Succ/Pred, division by zero, checked casts, union reads, allocation) writes one line naming the check and its location on stderr, then calls the weak hook sysl_trap(kind, a, b, length, at) before it traps. Contract failures no longer reach a sysl_bounds_fail override, as they did on 0.11.10–0.11.15: override sysl_trap instead. sysl_bounds_fail keeps its forms, and its default hands on to sysl_trap.
  • A panic aborts. panic, assert, assert_eq, unwrap, expect and the library's own panics write their report on stderr, tell sysl_trap, and call abort instead of exit(1), in executables and build-c libraries alike, so a C host's atexit handlers no longer run. On a freestanding target a panic still writes through putchar and calls exit(1).
  • A new type does not multiply or divide by itself. The product or quotient of two of its values is a different quantity, so a * b and a / b are refused, naming impl Mul / impl Div, which make them writable (with any result type). A literal is still a scale (d * 2), and %, + and - are unchanged.
  • A counted value that is not &sync may not be held across a call that can reach sysl.fiber.switch, since the fiber may resume on another thread. Mark a body @pinned(thread) to opt it out, or end the value's scope before the call.
  • A closure's capture mode is decided where the closure is written: by reference when handed to a @scoped parameter, by value when kept. Before, a later statement (a second keeping call, a defer, an assignment of None) could change the same line from a write to a copy. A program that relied on the old by-reference choice is refused by the lost-write rule, which names the mode; --explain-escapes now reports, for every such closure, which way it holds its captures and why.
  • Overloads read literal arithmetic and untyped constants as the literal they stand for. g(60 * 52) and g(K) with const K = 3120 over u32/u64 are ambiguous, as g(3120) is, instead of picking the narrowest type; an operator's right operand and a new type's own From[int] follow the same rule. Write u32(K) to choose.
  • Option[&T] and Option[&sync T] are one address, None being null. Option[*T] keeps its tag (Some(null) stays distinct from None), and is refused in an extern or @export signature: a nullable C pointer is a *T compared with null. An extern taking Option[&T] receives the same address a bare &T hands over.
  • libm functions need libc. sin, atan2, pow, cbrt, fmod and the special functions are @needs(libc), so a freestanding program reaching one is refused at the call unless its manifest grants libc (build-c then links m), instead of handed an archive whose link fails.
  • An executable seals its own functions. sysl build, sysl run and the test binary give every function of the program's own modules internal linkage unless it is an @export, placed in a section, or named by module asm, so LLVM can inline a function called once. emit-llvm, build-lib and build-c are unchanged.
  • sysl test --file builds only the @tests files it names and what they need. An error in an unnamed, unneeded @tests file is no longer reported by such a run. SYSL_TEST_EVERY_FILE=1 restores the whole build.

Added

  • Language
    • Trait objects answer is[T]() and as[T](), a checked downcast over the identity an object carries (as answers a counted &T, or an Option[*T] on a *Trait), and === / !== compare two objects by identity.
    • Patterns and operators reach through a reference: a shape matched through &T takes the referent apart, and a + b on &T operands resolves the referent's operator.
    • t[i, j]: a subscript with several indices, on a container indexed by a tuple or an array.
    • The one-tuple (x,), and written type lists over a pack.
    • impl[const N: usize] Tr for [N]u8: an impl for every array of one element type; an impl may also target a vector (<N>f32, <N>T).
    • A bare enum variant resolves from its own payload's shape, and may share a name with a module value.
    • An int and a usize meet where the value of one is known to fit the other's type.
    • A bare literal beside a typed argument takes the overload that argument matches exactly (nextafter(x, 100.0) with x: f32).
    • Function types may name their parameters (Fn(count: int), *extern(fd: i32)), ignored by type identity; a function type with no -> yields unit.
    • A destructor may take *self: Drop declares drop(*self) and the hook hands it the payload's own address.
    • A struct invariant clause may carry a message, reported when it fails.
    • volatile T under an Integer bound, []T widens to []volatile T, and a volatile-element array fills from a literal.
    • Constant evaluation reads and writes memory as another type (the bytes of its storage in the target's byte order), folds sqrt of a constant correctly rounded, and reads a reference's referent in a constant pattern.
  • Attributes and the C boundary
    • build-c --shared: a self-contained .dylib/.so exporting only the @export symbols. Headers spell *const T, void *, size_t/ptrdiff_t, array parameters and c type names, emit #defines from exported consts and enums, and take --header-guard.
    • r.into_raw() and sysl.raw.from_raw(p): a counted reference given up as a *T and adopted back.
    • @abandons on an extern that answers a value (lua_call), and @abandons *extern function pointers, for C catch points.
    • @link(framework: "Name") for macOS frameworks, refused on targets without them.
    • A c const line may read a C string, as a string (a const holding C's literal) or a *u8 (a val over the c-string literal).
    • @extensions("…"): a function compiled for processor extensions the build does not promise, called from code that has them or inside @unchecked("…").
    • @no_recursion, @stack(n, calls: m) and sysl stack: a bound on a call tree's stack depth, checked on the optimized text.
    • @reassociate on a function, method or block, and @no_fuse, a body or module whose multiplies are never fused with the adds they feed.
    • Inline asm takes a vector register class (vreg) and inout operands, tied in place or into another variable.
  • Vectors
    • <N>U(v) converts lane-wise and <N>T(x) splats a scalar; sqrt, floor, ceil, round, trunc, bits()/from_bits; mask and table operations (m.bits(), table.lookup(idx), v.compress(m), xs.gather(idx)); an integer dot product accumulated in a wider integer; sysl.math.VectorFloat's lane-wise exp and tanh over <N>f32 and <N>f64.
  • Library
    • sysl.math.bigint: Karatsuba, Toom-3 and a number-theoretic-transform multiply and square, recursive division, divide-and-conquer text conversion, Lehmer and half-gcd, gcd_ext and mod_inverse, with AArch64 limb kernels.
    • sysl.checksum: crc32c (the instruction where the target has it, slice-by-8 elsewhere) and hash64 (rapidhash V3).
    • sysl.sync: SeqLock[T] and load_relaxed/store_relaxed, word-wise relaxed copies of plain data.
    • sysl.text: is_utf8 and validate_utf8, non-allocating; sysl.unicode.simple_fold.
    • sysl.fs: sync_data, full_sync, open_uncached, and a writable shared mapping with msync.
    • sysl.net: send_vectored, no_delay, reuse_port, keepalive. sysl.io.poll: Poller.fd() and WakeFd.
    • view_as[T](): a view read at another plain-data element, its owner kept, boundary and tail checked.
    • Buf.swap_remove, aligned[T](n, alignment), sysl.slices sum, dot and zeroize; Hash for slices, Buf, Option and Frozen, Eq for Frozen.
    • A named heap is told every block's size and alignment on alloc and free.
    • A string held by a &sync object or a &sync Fn is shared: copied into bytes with an atomic count where the box is made.

Improved

  • A box whose payload no code reaches without its type holds only its strong count, an object whose box holds nothing dies without the reaper, slot_storage(0) and a run-time [v; n] of zero allocate nothing, and a Buf's growth moves its elements (one memmove for elements holding no count) instead of copying them and dropping the old ones.
  • A closure that does not outlive its captures holds a captured val aggregate by address instead of copying it.
  • The byte search, from_utf8, from_utf8_lossy and rfind_byte_from go sixteen bytes at a time.

Fixed

  • Overflow reports name closure, nested-function and element operands as declared, and a type parameter's by its width.
  • A deref scrutinee matched where a fiber may move binds shares of the referent, not a copy of it.
  • A clause message naming a frame variable is refused as not constant, not as undefined.
  • A box's and a buffer's header pad covers every gap to the payload, computed from the layout's alignment.

Known issues

  • TernDB's suite has failures on 0.12.0 that are still being investigated.

Tests

  • Full suite on the release tree (SYSL_DOCS=1, stage 2): 26322 passed, 46 failed, 5 ignored. All 46 were tests and doc links that had not caught up with this release's changes; they were corrected, and the 26 files they live in, with the three pages whose links changed, then passed (401 tests and three docs sweeps, 0 failed). The stage-3 self check reports identical emit-llvm (2896894 lines).
  • --std: 2247 passed, 0 failed.
  • slate on the candidate: 2806 passed, 0 failed.