Beta Release 0.1.4

This is a small release that brings a big breaking change to most Onyx programs. In short, map.get now returns an Optional, instead of the value directly. This leads to cleaner and more understandable code.

Map uses Optional

The map.get procedure is now defined like so:

Map.get :: (m: &Map($K, $V), k: K) -> ? V { ... }

This is more idiomatic as now the procedure can actually return "no result", without returning a dummy default value. However, as Map is a core data structure used by many programs, this will break many programs. This is why this release is smaller than most, as I want to get this change out there. All libraries have been updated for this already.

To convert existing code, you will likely just need to add ?? .{} after the map.get or m[key]. This will provide a default value if None was returned.

A useful pattern I found myself using while converting the standard library was this:

m: Map(str, str);
// ...
m->get("some key")->with([the_value] {
    // Do something with "the_value"

The code inside of the with block is only executed if the value was present, so this acts like a map.has and map.get all at once.

Onyx package folder structure

In this version of Onyx, the package manager no longer outputs a flat directory structure for the included packages. Instead, the full path to the package is used.

For example, if you include, then the path to that library will be ./lib/ This way, package names do not have to be unique across the Onyx ecosystem, as this is impossible to enforce as Onyx does not have a centralized package version manager.

This change should be transparent so long as you are using the ./lib/packages.onyx file. The next time you run onyx package sync this new folder structure will be created and switched to.

Full Changelog

Release v0.1.4
22nd June 2023


- Deprecated `map.get_opt`.
    - This is unnecessary with the new semantics of `map.get`.

- `onyx pkg` now stores synchronized packages in a different folder hierarchy.
    - This is a transparent change so long as you use the `lib/packages.onyx` file.
- `Map` implementation no longer holds a default value. Instead, it returns an optional from `map.get`.
    - This is a significant breaking change that will affect many programs.

- Fixed a bug that made relative imports not always relative to the current file.
    - This may break some programs that were accidentally using this "feature".
- Fixed a bug with small a `union` over small data types, such as booleans.
    - There was an alignment issue, which caused the union to be smaller than expected.
© 2020-2024 Brendan Hansen