Skip to content

v1.0.0-rc.10

Pre-release
Pre-release

Choose a tag to compare

@dadolangcom dadolangcom released this 09 Nov 21:34
· 3 commits to main since this release

Breaking

  • ERR0540: a string literal made a cstring holds no NUL. cstring s = "a\0b" compiled and handed C "a", the rest lost without a word, since C reads a cstring to its first NUL; it is refused now wherever a literal becomes a cstring — 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 a string8, string16 or string32, whose length counts the NUL as one more unit. Write the literal without the \0, or keep bytes that hold one in a string8 or a []char8 and pass its pointer and length.

Added

  • Copying into a run that already exists. A slice assignment copies an exact window: dst[i..<j] = src, and dst[:] = src for the whole run; the lengths must be equal, which is ERR0617 when 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's copy does. Either side is a fixed array, a window or a ref []T; the destination is a place (ERR0606 for 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, as memmove'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" in docs/language.md.
  • T(), the zero initializer: for a declared type T, the value T t with no initializer gets — each slot at its default, zero where it has none — written as an expression (return T(), f(T())). Where T t is 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 over f32 and f64 (#abs, #min and #max over integers too), lowered to what the target has (libm or a builtin in C, Math on 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:math is 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 is ERR0402). died.connect(f), died.disconnect(f) and died.emit(hp) in a script; from Dado through a handle g of the class, g.died.connect(f) with a package-level function, or g.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 (ERR1206 for one that cannot).

Changed

  • The compiler is self-hosted. dadoc and dado-lsp are 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.sh compiles bootstrap/dadoc.c (the compiler's own C), then the compiler builds itself; no Rust or cargo is needed. Release archives ship dado beside dadoc and dado-lsp, and install.sh (install.bat) runs dado install (old: dadoc bootstrap, which the new dadoc does not have); an install keeps collections/language, from which dado update rebuilds dado. dadoc --version names the version on its first line, as before, and self-hosted (tools/dadoc) on its second (old: Rust's commit, build date, rustc and zig lines); dado-lsp --version names 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/dadoc 11.8 s (57.5 s), and 19.3 s with --release (74.3 s); dado build tools/dado 3.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 behind ERR0803 and WRN0803 checks 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.
  • WRN0803 warns 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 check and 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-c keeps it, and dadoc --emit=c (on standard output when no -o is given) writes the one-file C for reading.
  • ERR1029 checks a foreign name against the C names the compiler now writes, not rc.9's dado_<pkg>_<name> and dado_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 the h header declares a readable typedef for 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; write n := #copy_into(into, from) (the count, the shorter length), or into[:] = from when the lengths are equal (an exact window; see "Copying into a run that already exists" in docs/language.md).
  • dadoc --emit= ast, types, views, h, narrowings, raises, strategies, crossings and placement: no tool, editor or check of the toolchain read them (h is the h extension of --emit=manifest, through tools/manifest/h.mjs).
  • dadoc serve, launch, bootstrap, --emit=build and --transpile-cache=, and its web-page writer: dado does 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.