v0.3.0
Big release on compiler, library and ecosystem.
Big release on compiler, library and ecosystem.
Compiler/Library
- Reworked include resolve, now it doesn’t carry non-public imports from other modules and allows to do private elements with same name (added mangling for codegen stage)
- Fixed short circuit eval
&&and||(optimization and safety element, nowif (ptr != nullptr && *ptr == 1)won’t panic) - Production ready standard library expansion, see new modules in web docs
New library examples
std.process
use std.string;use std.process;
fn main() { let out = Command.new("echo") .arg("hi") .output() .expect("an error occured during command spawn");
@println("Output: {}", out.stdout.trim_end());}use std.process;
fn main() { let args_iter = Process.args_iter();
@println("Args without extra allocations:");
for (arg : args_iter) { @println("> `{}`", arg); }}std.threadandstd.sync
use std.sync;use std.thread;
fn main() { let counter = Arc.new(Mutex.new(0));
let c1 = counter.clone(); let c2 = counter.clone();
let t1 = Thread.spawn(fn() i32 { let guard = c1.get_mut().lock(); *guard = *guard + 1;
return *guard; });
let t2 = Thread.spawn(fn() i32 { let guard = c2.get_mut().lock(); *guard = *guard + 1;
return *guard; });
@println("t1 = {}", t1.join()); @println("t2 = {}", t2.join()); @println("counter = {}", (*counter.get()).into_inner());}std.env
use std.env;
fn main() { Env.set_var("ZEEN_TEST", "works!").expect("oops! error!");
@println( "{}", Env.var("ZEEN_TEST").expect("nothing here") );}std.path
use std.path;
fn main() { @println("{}", Path.join("/tmp", "a.txt"));}std.time
use std.time;
fn main() { let start = Instant.now(); Time.sleep(Duration.from_millis(512));
@println("{}", start.elapsed().as_millis());}std.json
use std.json;
fn main() { let source: []const char = r#" { "number": 42 } "#;
let parsed = JsonValue.parse(source).expect("parser error");
switch (parsed.get("number")) { .Some(n) => { @println("Number is: {}", n.as_i64().expect("not a number")); },
_ => @println("Nothing!"), }}std.log
use std.log;
fn main() { Log.set_level(Level.Info); Log.info("Logging works!");}std.crypto
use std.crypto.sha256;use std.crypto.base64;
fn main() { @println("sha = {}", Sha256.hexdigest("Hello!")); @println("base64 = {}", Base64.encode("Hello!"));}LSP
LSP Server got a huge update, fixed a lot of bugs related to hovers, goto’s, defs, autocompletes and etc.
- Added codelens elements support (such as “Run”/“Test”, references counter, rename symbol, symbols map and etc.)
- Added more useful info in hover (fixed syntax highlight, added more types display,
Drop/NoDropmark, copy/move-only mark and etc.) - Really expanded autocompletes: structs fields, enums variants, static/instance method, interfaces, implement blocks and more more!
Editors
- Added VS Code static json language description for parser
- Added tree-sitter parser support for Neovim
(NEW) Package Manager
Designed and implemented cargo-like package manager. Packages can be used from any git repository (github, codeberg, gitlab and etc.), their revs and states are locked in Zora.lock (coming right from Zora.toml main manifest). Optimized with databases and git checkouts in home directory that is shared across projects on your computer.
Also, Zora is now connected with LSP server, so just open your Zora project in editor and it will work as expected (I hope so, works on my machine).
Zora Project Layout:
Directorymy-project
- Zora.toml project manifest
- Zora.lock resolved dependencies
- .gitignore
Directorysrc
- main.zn entry point (
bin), or index.zn (lib/*)
- main.zn entry point (
Directorydist/ build output
- …
Quick Start:
zora new hello_worldcd hello_worldzora runBreaking Changes
- Standard library is a Zora project now, it contains toml manifest and etc. This will NOT affect the way you interact with the library, old code still works fine.
Pull Requests Changelog
- Include resolver rework by @mealet in https://github.com/mealet/zeen/pull/58
- Short circuit eval for
&&and||by @mealet in https://github.com/mealet/zeen/pull/59 - Standard library expansion by @mealet in https://github.com/mealet/zeen/pull/61
