Repository navigation
·
10 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
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. akaandanywayare keywords. Rename a variable, function, or field with either name.showandequalsare hooks. A methodshowwith parameters, orequalswithout exactly one, no longer compiles, andshowmust return its text. Rename the
method or return the text.- A second
suchof a name in the same scope is an error (E0302) instead of a reassignment. Dropsuchto 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
soconstant 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". Compareerr.typeor useisa(err, KeyError). err.messagesays only what went wrong; the fix moved toerr.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; writelist(range(n))where a List is needed.List.index_ofgivesnonefor a missing item instead of raising. Test the result with== none.x in dwith a value that cannot be a Dict key is aTypeErrorinstead offalse. Convert first withint(x)orstr(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. 010is a compile error: write0o10or10. 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 / Intdivides exactly and rounds once. - A Decimal and a Float compare exactly:
dec("0.1") == 0.1isfalse. 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
Overflowinstead of exhausting memory (a number past 32 MiB, a hugerangeor repetition);crypto.tokentakes at most 1
MiB per call. - Two bound methods are equal only when bound to the very same List or Dict.
nap.parsereads RFC 3339 and rejects text without a zone and dates that do not exist. Add the zone to the text you parse.json.parserejects 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 checkprints nothing for a clean script. Rely on the exit status;doge check --aststill prints the tree.doge testruns a file's top-level code first and captures test output, showing it only for a failing test (--nocaptureshows all). Move code that must not run
underdoge testinto a function.- A bare
dogewith piped stdin runs it as a script. Usedoge replto drive the REPL from a pipe. doge.tomlis validated (SemVerversion, a validname, anentryinside the project, unique dependency aliases). Fix the line the error names.doge newrefuses a name that does not start with a letter.Bytes.findis removed. Useb.index_of(needle, start), which givesnoneinstead of-1.
Language
- Lambdas:
much x, y: x + yis a function value with defaults andmany rest. - Comprehensions:
[x * 2 for x in xs if x > 0], plus Dict and Set comprehensions with any number offorandifclauses. - Spread:
f(1, many xs)passes a List's items as separate arguments,superincluded. - 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 afterplsthat 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 haserr.hint. - Class constants, empty class bodies, parents from an imported module, and
superinside lambdas, nested functions, and comprehensions. - Display and equality hooks:
such show:andsuch 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
noneas 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)andisa(x, Class);sorted,sum,min,max,enumerate,zip,list,char;rangewith a step;int(text, base).- Str methods:
split,lines,trim,starts_with,ends_with,index_of,count,replace,upper,lower, padding, character tests, andparts.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, andround(x, digits).env:exit,whine(a line to stderr), andslurp(all of stdin).crypto:sha512, and password hashing with Argon2id.chase.runoptions for timeout, working directory, environment, and Bytes;howl.requestoptions for timeout, size limit, and Bytes, with proxy support;
pack.closeand a timeout onpack.sniff.
Errors and diagnostics
- Every compile diagnostic has a code,
file:line:column, a caret under the exact range, and an entry thatdoge 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, anddoge help. doge checkanddoge fmttake several files and directories;doge check --format jsonand--deny-warnings;doge fmt --diffand stdin.doge testfinds every test file in the project and takes--filter,--nocapture, and--junit.doge build -oand--target;--coloron every command;--lockedkeepsdoge.lockas 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
stringsmodule: 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.minandnerd.max: use the builtinsmin([a, b])andmax([a, b]).Dict.remove(key): used.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
dogeis 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