From 53ce89eb6946852a07a1f4dd203f110c30c1af00 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 22 Jun 2023 22:21:03 -0500 Subject: [PATCH] added: release 0.1.4 page --- onyx-pkg.ini | 7 +-- src/app.onyx | 3 +- www/news-articles/index.json | 6 ++ www/news-articles/release-0.1.4.html | 91 ++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 www/news-articles/release-0.1.4.html diff --git a/onyx-pkg.ini b/onyx-pkg.ini index f874f68..e6a7bc9 100644 --- a/onyx-pkg.ini +++ b/onyx-pkg.ini @@ -10,15 +10,12 @@ lib_source_directory=./lib lib_bin_directory=./bin run_cmd=onyx run build debug_cmd=onyx run --debug build -test_cmd= [native_library] -build_cmd= -library= [dependencies] -git://onyxlang.io/repo/http-server=0.2.8 -git://onyxlang.io/repo/otmp=0.0.14 +git://onyxlang.io/repo/http-server=0.2.10 +git://onyxlang.io/repo/otmp=0.0.16 [dependency_folders] git://onyxlang.io/repo/http-server=http-server diff --git a/src/app.onyx b/src/app.onyx index 5a2a8e0..0bde668 100644 --- a/src/app.onyx +++ b/src/app.onyx @@ -48,7 +48,8 @@ news_articles: Cached_Resource([] Article); @route.{.GET, "/news/:article"} (req: &Req, res: &Res) { - article := array.first(news_articles->get() ?? .[], [n](n.path == req.url_params["article"])); + article_path := req.url_params["article"] ?? ""; + article := array.first(news_articles->get() ?? .[], [n](n.path == article_path)); if !article { res->status(404); res->render("pages/404", null); diff --git a/www/news-articles/index.json b/www/news-articles/index.json index 955b111..bec20b7 100644 --- a/www/news-articles/index.json +++ b/www/news-articles/index.json @@ -1,4 +1,10 @@ [ + { + "name": "Beta Release 0.1.4", + "path": "release-0.1.4", + "date": "22nd June 2023", + "description": "Onyx's beta 0.1.4 release" + }, { "name": "Beta Release 0.1.3", "path": "release-0.1.3", diff --git a/www/news-articles/release-0.1.4.html b/www/news-articles/release-0.1.4.html new file mode 100644 index 0000000..01bc1a4 --- /dev/null +++ b/www/news-articles/release-0.1.4.html @@ -0,0 +1,91 @@ +

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. +

+ +

+The Onyx package manager also sees a small update in the outputted library directory when packages are synchronized. +Assuming you are using the provided packages.onyx file, this should be a transparent change. +

+ +

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"
+    println(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 https://github.com/someuser/somepackage, then the path to that library will be ./lib/github.com/someuser/somepackage. +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
+
+Additions:
+
+Removals:
+- Deprecated `map.get_opt`.
+    - This is unnecessary with the new semantics of `map.get`.
+
+Changes:
+- `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.
+
+Bugfixes:
+- 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.
+
-- 2.25.1