Repository navigation
Sword 0.2.1 — Fold
2026-10-20. A patch to Fold that finishes the way out to C: a library named in the
source and linked either way, a C function as a value, and a library loaded
while the program runs.
What changes for existing programs
- The name of an
externfunction, used as a value, is anextern func,
not afunc. Code that handed one where afuncwas expected no longer
compiles; afunccan only point at Sword code, which is what letsdet
follow a call through one. - An integer narrower than 32 bits reaches C widened. On Apple's arm64 an
externtaking anint8_t, anint16_tor aboolread whatever the upper
bits of the register held. - Every function but
mainis internal to the program. LLVM drops what
nothing calls: on an Apple M4 a hello world went from 145 376 to 119 400 bytes
and the HTTP test from 281 752 to 168 552, and building the latter takes about
half the time. A program that uses part of a package no longer references the
C symbols the rest of it needs.
C
extern "z" func ...names the library a function comes from, and it is
linked without being mentioned on the command line. pkg-config is asked where
it is when the machine has pkg-config.shield --staticlinks each declared library from its archive and refuses
to build without one. The system's own libraries stay dynamic.extern weak func ...— a function the program can run without. Its name
is an?extern func, to be checked before it is called.extern func(T) R— a C function as a value. A Sword function converts to
one, which is howqsortgets a comparison; an address converts to one, which
is how a loader's answer gets a type.std/dlopens a library while the program runs, finds functions in it,
and keeps the system's own account of what went wrong inLoader.Why().--emit-linkprints the rest of the link line, for a build that links by
its own means.
Other machines
--target=<triple>builds for another 64-bit, little-endian machine,
against a runtime built for it withmake TARGET=<triple>.-cstops at
the object file and needs nothing but clang.
Fixes
shield teston a program — a package with amain— failed in clang every
time (#4).- A function can return a function value; the parser read the result type as
the start of the body. - Two copies of the test suite on one machine no longer overwrite each other's
certificates, files and test binaries (#36), andshield testno longer puts
a binary beside the package for the length of a run. - The value of
shield test -preached the shell unquoted. -simwarns about a call through anextern func, as it does about a call to
anexterndeclaration.