Skip to main content

Hew 0.6.2: safer values, steadier services

· 5 min read
v0.6.2

A service often needs to read configuration, adjust a value for one run, and keep the original available for logging or comparison. Hew 0.6.2 makes that kind of update easier to reason about: parsed TOML values clean themselves up, and copying one gives you an independent value to edit.

Edit a value without changing its source

Save this as config.hew:

import std.encoding.toml;
 
fn main() {
    let source = toml.parse("port = 8000").expect("valid TOML");
    var local = source;
    local.set("port", toml.from_int(9000)).expect("table");
 
    let configured = source.get_field("port").expect("table").expect("port");
    let selected = local.get_field("port").expect("table").expect("port");
    println(configured.get_int().expect("integer"));
    println(selected.get_int().expect("integer"));
}

Run it with hew run config.hew:

8000
9000

source stays immutable. The var binding lets this function update its own copy, and set reports an error if the value is not a table. Each lookup also checks the value kind and whether the key exists. When the function ends, both values are cleaned up automatically. You can pass a child value to set and keep using it afterward; inserting it no longer consumes the child.

The same checked model applies to arrays and scalar getters. A missing field is None, while asking a value of the wrong kind for a field is an access error. This keeps absence distinct from malformed input and from a caller asking the wrong question.

Keep one actor type as a service moves

A service can begin as a local actor and later run under supervision or on an authenticated peer. In 0.6.2, its declared actor type is also its reference type in each place. A Counter field or parameter stays Counter; separate ChildRef<Counter>, RemotePid<Counter> and net.Service<Counter> wrappers are gone.

For a remote service, discovery gives you a Location, which identifies a service but cannot call it. An authenticated peer session admits a service grant; the recipient receives an ordinary actor reference and calls its declared handlers. The issuer keeps the export alive while recipients may use that grant, and closing it revokes the grant. Upgrade communicating nodes together: protocol 8 is incompatible with earlier versions. The migration guide explains exporting, receiving and revoking grants, and how to handle a request whose remote admission is uncertain.

Actor lifecycle observation follows the same identity model. A stable supervised role resolves to its replacement after a restart, while a reference returned by a worker still names that worker’s incarnation. stopped(actor) waits for terminal cleanup without reporting the actor’s original crash a second time; faults raised during cleanup remain observable.

Upgrade your project

Install Hew 0.6.2, then read the migration guide before rebuilding:

curl -fsSL https://hew.sh/install | bash -s -- --version 0.6.2

If your program uses TOML values, remove manual free() and close() calls. Replace consuming with_* and push_* builders with set and push on a var value, and replace toml.stringify(value) with value.stringify(). Update old string indexing and sorting helper names: strings now index Unicode scalar values, and the migration guide lists each removed alias and its replacement.

If you run communicating actors, update every peer together to protocol 8. Rebuild native libraries that exchange Hew-managed strings with the matching compiler and runtime, because the string layout changed. Update editor launch settings from hew-lsp and hew-observe to hew lsp and hew observe; the toolchain now ships one hew executable.

The 0.6.2 release notes describe the remaining actor, collection, library and publishing changes. Install the matching SDK, apply the migration guide, then run your project’s checks before deploying the upgraded services.

Hew Notes

Language development, engineering articles, releases and community projects. About once a month, with an extra issue for a significant release. Written in English.

Subscribe to Hew Notes