Skip to content

v0.4.0

Latest

Choose a tag to compare

@github-actions github-actions released this 05 Dec 16:00
· 10 commits to main since this release
Immutable release. Only release title and notes can be modified.
ee5f7d3

What's New in v0.4.0

Much exact, very helpful, wow.

Doge 0.4.0 makes the language more powerful and more predictable. It adds lambdas, comprehensions, error classes, cleanup blocks, and format specs. Every error points at
the exact spot with a concrete fix, the tools are complete, and a script prints the same output whether it is compiled or run directly.

Breaking changes and migration

  • Rust 1.86 or newer is required (was 1.74). Run rustup update stable.
  • aka and anyway are keywords. Rename a variable, function, or field with either name.
  • show and equals are hooks. A method show with parameters, or equals without exactly one, no longer compiles, and show must return its text. Rename the
    method or return the text.
  • A second such of a name in the same scope is an error (E0302) instead of a reassignment. Drop such to reassign.
  • Reading a variable that some path has not set is a compile error (E0311) instead of none. Declare it before the block (such found = none).
  • Loop variables and caught errors live only inside their loop or handler. Read a value after the loop through a variable declared before it.
  • A binding with a builtin's name shadows it in its whole scope (warning W0303). Rename the binding to keep the builtin.
  • A so constant cannot be bound again in its scope (E0304). Pick another name.
  • A caught error is an object of its error class: type(err) is "KeyError" rather than "Error". Compare err.type or use isa(err, KeyError).
  • err.message says only what went wrong; the fix moved to err.hint. Code that matched the old message text must drop the fix part.
  • range(...) is a lazy Range, not a List. for, len, in, indexing, and slicing work as before; write list(range(n)) where a List is needed.
  • List.index_of gives none for a missing item instead of raising. Test the result with == none.
  • x in d with a value that cannot be a Dict key is a TypeError instead of false. Convert first with int(x) or str(x).
  • x.name(args) calls a field holding a function before a method of that name. Rename the field to keep calling the method.
  • A Str inside a List or Dict prints as an escaped literal (["a\"b"]). Print the items themselves for their raw text.
  • 010 is a compile error: write 0o10 or 10. A number glued to a keyword (1if) is one too.
  • Mixing an Int with a Float stays exact or raises Overflow; it never turns a huge Int into infinity. Int / Int divides exactly and rounds once.
  • A Decimal and a Float compare exactly: dec("0.1") == 0.1 is false. Convert to one type first.
  • NaN follows IEEE 754: comparisons with NaN are false, and sorting puts NaN last.
  • Huge numbers and sizes raise a catchable Overflow instead of exhausting memory (a number past 32 MiB, a huge range or repetition); crypto.token takes at most 1
    MiB per call.
  • Two bound methods are equal only when bound to the very same List or Dict.
  • nap.parse reads RFC 3339 and rejects text without a zone and dates that do not exist. Add the zone to the text you parse.
  • json.parse rejects a number with a leading zero (01).
  • doge check, the language server, and the REPL report every call error a build reports, so they reject programs they used to accept.
  • doge check prints nothing for a clean script. Rely on the exit status; doge check --ast still prints the tree.
  • doge test runs a file's top-level code first and captures test output, showing it only for a failing test (--nocapture shows all). Move code that must not run
    under doge test into a function.
  • A bare doge with piped stdin runs it as a script. Use doge repl to drive the REPL from a pipe.
  • doge.toml is validated (SemVer version, a valid name, an entry inside the project, unique dependency aliases). Fix the line the error names.
  • doge new refuses a name that does not start with a letter.
  • Bytes.find is removed. Use b.index_of(needle, start), which gives none instead of -1.

Language

  • Lambdas: much x, y: x + y is a function value with defaults and many rest.
  • Comprehensions: [x * 2 for x in xs if x > 0], plus Dict and Set comprehensions with any number of for and if clauses.
  • Spread: f(1, many xs) passes a List's items as separate arguments, super included.
  • Keyword arguments on every call, including methods, super.init, lambdas, and the optional parameters of builtins and stdlib functions (sorted(xs, reverse = true)).
  • anyway: a cleanup block after pls that runs once on every way out.
  • Error classes: many DogMissing much Error: defines your own, bonk DogMissing("walter") raises it, oh no err! binds the same object, isa(err, KeyError)
    catches a family, and every error has err.hint.
  • Class constants, empty class bodies, parents from an imported module, and super inside lambdas, nested functions, and comprehensions.
  • Display and equality hooks: such show: and such equals much other:.
  • Import aliases: so nerd aka n.
  • Sets: {1, 2}, set(), add/remove/is_subset, and |, &, -, ^.
  • Dict keys may be an Int, Bool, or none as well as a Str.
  • Raw strings r"…", multiline strings """…""", and format specs in interpolation: "{price:,.2f}", "{n:>6}", "{share:.1%}".
  • Number literals in hex, octal, and binary, _ between digits, and exponents.
  • Lists compare with < in sort order, and a collection that holds itself prints [...] instead of recursing forever.

Builtins and standard library

  • type(x) and isa(x, Class); sorted, sum, min, max, enumerate, zip, list, char; range with a step; int(text, base).
  • Str methods: split, lines, trim, starts_with, ends_with, index_of, count, replace, upper, lower, padding, character tests, and parts.join(sep).
  • List, Dict, and Bytes methods: pop, extend, copy, count, index_of, sort(key, reverse), get(key, default), update, and more.
  • nerd: log, exp, trigonometry, isnan, isinf, inf, nan, and round(x, digits).
  • env: exit, whine (a line to stderr), and slurp (all of stdin).
  • crypto: sha512, and password hashing with Argon2id.
  • chase.run options for timeout, working directory, environment, and Bytes; howl.request options for timeout, size limit, and Bytes, with proxy support;
    pack.close and a timeout on pack.sniff.

Errors and diagnostics

  • Every compile diagnostic has a code, file:line:column, a caret under the exact range, and an entry that doge explain <code> prints.
  • Every error in a file is reported in one run, with warnings for unreachable code and unused imports and locals.
  • "Did you mean" hints for misspellings, and doge spellings for another language's syntax (print(x), &&, else if, null, …).
  • An uncaught runtime error names its type, points a caret at the failing expression, lists the calls that led there, and ends with a such fix: hint.

Tools

  • New commands: doge init, doge update, doge explain, doge cache clean, and doge help.
  • doge check and doge fmt take several files and directories; doge check --format json and --deny-warnings; doge fmt --diff and stdin.
  • doge test finds every test file in the project and takes --filter, --nocapture, and --junit.
  • doge build -o and --target; --color on every command; --locked keeps doge.lock as it is.
  • The REPL is a full line editor with history, search, completion, :load, :reload, and :reset.
  • The language server adds hover, go to definition, find references, rename, outline, formatting, and quick fixes.

Faster and sturdier

  • Faster programs and builds: in-place string appends, constant-time string indexing, and large programs build on every core.
  • File, network, and HTTP failures are explained in plain words with a fix.
  • Built binaries contain none of your comments or local paths.
  • Many fixes across the REPL, doge test, doge fmt, the language server, and the standard library. See the changelog.

Deprecated

  • The strings module: each call warns with its method replacement (s.upper(), s.trim(), parts.join(sep), …), which editors apply as a quick fix. It goes away in
    the next release.
  • nerd.min and nerd.max: use the builtins min([a, b]) and max([a, b]).
  • Dict.remove(key): use d.pop(key).

VS Code extension

  • Hover, go to definition, find references, rename, outline, formatting, and quick fixes through doge lsp.
  • Highlighting for raw and multiline strings and format specs, and better indentation and folding.
  • A restart command, a trace setting, install help when doge is missing, and Workspace Trust support.
  • The extension's version now follows doge's and is attached to every release.

Install

Download the archive for your platform below, or:

cargo binstall dogelang        # prebuilt binary
cargo install --locked dogelang
code --install-extension doge-vscode-0.4.0.vsix   # the VS Code extension

Verify a download:

sha256sum --check --ignore-missing SHA256SUMS
gh attestation verify doge-v0.4.0-<target>.tar.gz --repo DogeLanguage/doge

Full Changelog: v0.3.6...v0.4.0