Repository navigation
v1.0.0-rc.10
Pre-release
Pre-release
Breaking
ERR0540: a string literal made acstringholds no NUL.cstring s = "a\0b"compiled and handed C"a", the rest lost without a word, since C reads acstringto its first NUL; it is refused now wherever a literal becomes acstring— a binding, a constant, an argument, a return, a default,cstring("…")— and the message names the byte and what C would read. The same literal still fits astring8,string16orstring32, whose length counts the NUL as one more unit. Write the literal without the\0, or keep bytes that hold one in astring8or a[]char8and pass its pointer and length.
Added
- Copying into a run that already exists. A slice assignment copies an exact window:
dst[i..<j] = src, anddst[:] = srcfor the whole run; the lengths must be equal, which isERR0617when both are known before the program runs and otherwise a trap naming both.n := #copy_into(dst, src)copies as many elements as both hold, from the start of each, and answers the count (i64), as Go'scopydoes. Either side is a fixed array, a window or aref []T; the destination is a place (ERR0606for a[]const T), the element types are the same (ERR0618: a copy converts nothing), strings, maps, pointers and single values are refused (ERR0619), and the two may overlap, asmemmove's may (xs[1..<n] = xs[0..<n - 1]shifts a run up by one). Native and the web; DadoScript has neither form. See "Copying into a run that already exists" indocs/language.md. T(), the zero initializer: for a declared typeT, the valueT twith no initializer gets — each slot at its default, zero where it has none — written as an expression (return T(),f(T())). WhereT tis refused,T()is refused the same way.- Math intrinsics:
#sin #cos #tan #asin #acos #atan #atan2 #sinh #cosh #tanh #asinh #acosh #atanh #pow #sqrt #cbrt #exp #exp2 #log #log2 #log10 #fma #floor #ceil #round #trunc #abs #min #max, generic overf32andf64(#abs,#minand#maxover integers too), lowered to what the target has (libm or a builtin in C,Mathon the web). DadoScript has them as globals (sin(),pow()), which a declaration of the same name shadows. A call whose arguments are constants folds, with the target's own implementation where the compiler has it and the host's libm otherwise. Results may differ in the last bits between targets;core:mathis unchanged, for results that must not. - Signals in DadoScript:
signal died(int hp)declares one in a script class, beside its fields and methods (a field, method or signal of one name isERR0402).died.connect(f),died.disconnect(f)anddied.emit(hp)in a script; from Dado through a handlegof the class,g.died.connect(f)with a package-level function, org.died.connect(T.m, p)with a method bound to a pointer. An emit is synchronous: it calls every connection now, on the emitter's thread, in connect order; connecting one already there does nothing, and a receiver's parameters cross as a script's call of a Dado function's do (ERR1206for one that cannot).
Changed
- The compiler is self-hosted.
dadocanddado-lspare written in Dado (collections/language,tools/dadoc,tools/lsp) and the Rust compiler is retired. A checkout builds with a C compiler alone:./dado_build.shcompilesbootstrap/dadoc.c(the compiler's own C), then the compiler builds itself; no Rust or cargo is needed. Release archives shipdadobesidedadocanddado-lsp, andinstall.sh(install.bat) runsdado install(old:dadoc bootstrap, which the newdadocdoes not have); an install keepscollections/language, from whichdado updaterebuildsdado.dadoc --versionnames the version on its first line, as before, andself-hosted (tools/dadoc)on its second (old: Rust's commit, build date, rustc and zig lines);dado-lsp --versionnames the release (dado-lsp 1.0.0-rc.10). - Builds are faster from cold, and the C a build compiles is smaller. Measured on a 4-core Linux machine with gcc, each against rc.9's compiler:
dado build tools/dadoc11.8 s (57.5 s), and 19.3 s with--release(74.3 s);dado build tools/dado3.5 s (4.1 s), 5.4 s with--release(7.3 s); a small program,corpus/asteroids, 0.19 s (0.39 s). A many-file build's C is 36–49% smaller, since each file's header holds only what its code uses. Builds with nothing changed take what they did (the caches'). Checking runs at 266,000–716,000 lines a second through the type checker (rc.9's: 31,000–168,000), and the ownership analysis behindERR0803andWRN0803checks the compiler's own 75,000 lines in 1.1 s, where rc.9's took 37 s over the 59,000 it had then. Built programs run within 5% of rc.9's, native, on the web and in DadoScript, dev and release. - The many-file form is cut by source file, where it was cut by package: a dev or test build compiles a C file per source file, a release build gathers files into C files of up to 512 KiB (
DADO_UNIT_BYTES;0, a file each). - Diagnostics are listed in order of phase, then file, then position (rc.9: the order they were found), so when there are more errors than are printed in full (12), the ones shown can be different ones.
WRN0803warns where a hazard is real: sites rc.9 warned at that cannot dangle (a view of text kept in package storage while a run of another type grows, a field path the moved run is not on, …) are no longer warned about.dado checkand the editor analyse every library body, reached or not; a build analyses the bodies the program reaches (rc.9: both).- The C a build writes only to hand to the C compiler is deleted after it runs, whether it succeeded or not (rc.9 left it in the build directory):
dado build --keep-ckeeps it, anddadoc --emit=c(on standard output when no-ois given) writes the one-file C for reading. ERR1029checks aforeignname against the C names the compiler now writes, not rc.9'sdado_<pkg>_<name>anddado_tupN_…spellings.dadoc --emit=manifest: the C spellings in it (symbols' parameter names, shapes' C names, member names and offsets,header.declarations) are the new compiler's, and thehheader declares a readabletypedeffor each exported shape — its declared name, and for a shape written out its old mangled name (dado_tup2_i32_i32) — so C that calls a library never names a hashed type.- In a file that does not parse, the editor shows the syntax errors and fewer of the checker's errors that follow from them.
Removed
core:slices:copy_into(from, into). Its order was the reverse of the#copy_into(dst, src)builtin's; writen := #copy_into(into, from)(the count, the shorter length), orinto[:] = fromwhen the lengths are equal (an exact window; see "Copying into a run that already exists" indocs/language.md).dadoc --emit=ast,types,views,h,narrowings,raises,strategies,crossingsandplacement: no tool, editor or check of the toolchain read them (his thehextension of--emit=manifest, throughtools/manifest/h.mjs).dadoc serve,launch,bootstrap,--emit=buildand--transpile-cache=, and its web-page writer:dadodoes each (dado install,dado build,--build-manifest=, the driver's own caches).dado-lsp: completion, code actions and rename, which the Rust server had; diagnostics, hover and go to definition remain. They return in a later release.