Repository navigation
sysl 0.12.0
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 hooksysl_trap(kind, a, b, length, at)before it traps. Contract failures no longer reach asysl_bounds_failoverride, as they did on 0.11.10–0.11.15: overridesysl_trapinstead.sysl_bounds_failkeeps its forms, and its default hands on tosysl_trap. - A panic aborts.
panic,assert,assert_eq,unwrap,expectand the library's own panics write their report on stderr, tellsysl_trap, and callabortinstead ofexit(1), in executables andbuild-clibraries alike, so a C host'satexithandlers no longer run. On a freestanding target a panic still writes throughputcharand callsexit(1). - A
newtype does not multiply or divide by itself. The product or quotient of two of its values is a different quantity, soa * banda / bare refused, namingimpl 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
&syncmay not be held across a call that can reachsysl.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
@scopedparameter, by value when kept. Before, a later statement (a second keeping call, adefer, an assignment ofNone) 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-escapesnow 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)andg(K)withconst K = 3120overu32/u64are ambiguous, asg(3120)is, instead of picking the narrowest type; an operator's right operand and a new type's ownFrom[int]follow the same rule. Writeu32(K)to choose. Option[&T]andOption[&sync T]are one address,Nonebeing null.Option[*T]keeps its tag (Some(null)stays distinct fromNone), and is refused in anexternor@exportsignature: a nullable C pointer is a*Tcompared with null. AnexterntakingOption[&T]receives the same address a bare&Thands over.- libm functions need libc.
sin,atan2,pow,cbrt,fmodand the special functions are@needs(libc), so a freestanding program reaching one is refused at the call unless its manifest grantslibc(build-cthen linksm), instead of handed an archive whose link fails. - An executable seals its own functions.
sysl build,sysl runand 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 moduleasm, so LLVM can inline a function called once.emit-llvm,build-libandbuild-care unchanged. sysl test --filebuilds only the@testsfiles it names and what they need. An error in an unnamed, unneeded@testsfile is no longer reported by such a run.SYSL_TEST_EVERY_FILE=1restores the whole build.
Added
- Language
- Trait objects answer
is[T]()andas[T](), a checked downcast over the identity an object carries (asanswers a counted&T, or anOption[*T]on a*Trait), and===/!==compare two objects by identity. - Patterns and operators reach through a reference: a shape matched through
&Ttakes the referent apart, anda + bon&Toperands 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
intand ausizemeet 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)withx: f32). - Function types may name their parameters (
Fn(count: int),*extern(fd: i32)), ignored by type identity; a function type with no->yieldsunit. - A destructor may take
*self:Dropdeclaresdrop(*self)and the hook hands it the payload's own address. - A struct invariant clause may carry a message, reported when it fails.
volatile Tunder anIntegerbound,[]Twidens 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
sqrtof a constant correctly rounded, and reads a reference's referent in a constant pattern.
- Trait objects answer
- Attributes and the C boundary
build-c --shared: a self-contained.dylib/.soexporting only the@exportsymbols. 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()andsysl.raw.from_raw(p): a counted reference given up as a*Tand adopted back.@abandonson an extern that answers a value (lua_call), and@abandons *externfunction pointers, for C catch points.@link(framework: "Name")for macOS frameworks, refused on targets without them.- A
c constline may read a C string, as astring(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)andsysl stack: a bound on a call tree's stack depth, checked on the optimized text.@reassociateon a function, method or block, and@no_fuse, a body or module whose multiplies are never fused with the adds they feed.- Inline
asmtakes a vector register class (vreg) andinoutoperands, 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-wiseexpandtanhover<N>f32and<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_extandmod_inverse, with AArch64 limb kernels.sysl.checksum:crc32c(the instruction where the target has it, slice-by-8 elsewhere) andhash64(rapidhash V3).sysl.sync:SeqLock[T]andload_relaxed/store_relaxed, word-wise relaxed copies of plain data.sysl.text:is_utf8andvalidate_utf8, non-allocating;sysl.unicode.simple_fold.sysl.fs:sync_data,full_sync,open_uncached, and a writable shared mapping withmsync.sysl.net:send_vectored,no_delay,reuse_port,keepalive.sysl.io.poll:Poller.fd()andWakeFd.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.slicessum,dotandzeroize;Hashfor slices,Buf,OptionandFrozen,EqforFrozen.- A named heap is told every block's size and alignment on
allocandfree. - A string held by a
&syncobject or a&sync Fnis 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 aBuf's growth moves its elements (onememmovefor elements holding no count) instead of copying them and dropping the old ones. - A closure that does not outlive its captures holds a captured
valaggregate by address instead of copying it. - The byte search,
from_utf8,from_utf8_lossyandrfind_byte_fromgo 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.