added release 0.1.2
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 31 May 2023 00:24:31 +0000 (19:24 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 31 May 2023 00:24:31 +0000 (19:24 -0500)
onyx-pkg.ini
www/news-articles/index.json
www/news-articles/release-0.1.2.html [new file with mode: 0644]
www/static/css/new_style.css
www/static/font/FiraCode-Regular.woff [new file with mode: 0644]

index 40ec349cd3f66d497384a8e2d300b944b2319657..6154398b568298c3ef4271439228791887bd7011 100644 (file)
@@ -17,8 +17,8 @@ build_cmd=
 library=
 
 [dependencies]
-git://onyxlang.io/repo/http-server=0.2.1
-git://onyxlang.io/repo/otmp=0.0.12
+git://onyxlang.io/repo/http-server=0.2.4
+git://onyxlang.io/repo/otmp=0.0.13
 
 [dependency_folders]
 git://onyxlang.io/repo/http-server=http-server
index 04210d5ada3ac19f4a02c1469ea081037a386009..9e6a79caed3905891239face16464955f3d495a0 100644 (file)
@@ -1,4 +1,10 @@
 [
+    {
+        "name": "Beta Release 0.1.2",
+        "path": "release-0.1.2",
+        "date": "28th May 2023",
+        "description": "Onyx's beta 0.1.2 release"
+    },
     {
         "name": "Beta Release 0.1.1",
         "path": "release-0.1.1",
diff --git a/www/news-articles/release-0.1.2.html b/www/news-articles/release-0.1.2.html
new file mode 100644 (file)
index 0000000..aecd77b
--- /dev/null
@@ -0,0 +1,137 @@
+<h1>Beta Release 0.1.2</h1>
+
+<p>
+    This release of Onyx brings a substantial new feature called <em>tagged unions</em>, and a collection of other small bugfixes.
+</p>
+
+<h2>Tagged Unions</h2>
+<p>
+    Tagged unions are a big addition to the type system in Onyx, as they allow you to represent a new <em>kind</em> of type.
+    They bring a number of safety and sanity features that Onyx had been lacking in its type system.
+</p>
+
+<p>
+    At their core, tagged unions store at most one type of data at a time, and know which type they are currently holding.
+    In order to use the data in the tagged union, you must do a <code>switch</code> statement, which guarantees that you can only access the data if it is of the correct type.
+</p>
+
+<p>
+    Let's look at a code example.
+</p>
+
+<pre class="hljs"><code class="language-onyx">
+MultipleTypes :: union {
+    int: i32;
+    float: f32;
+    string: str;
+}   
+
+main :: () {
+    value := MultipleTypes.{ string="Tagged unions are cool!" };
+
+    switch value {
+        case .int do println("It was an integer!");
+        case .float do println("It was a float!");
+        case .string do println("It was a string!");
+    }
+}
+</code></pre>
+
+<p>
+    This code will print <code>It was a string!</code>, because <code>value</code> currently holds the <code>string</code> variant.
+    This is specified with <code>MultipleTypes.{ XXX = ... }</code>; <code>XXX</code> must be one of the variants of <code>MultipleTypes</code>.
+</p>
+
+<p>
+    In order to access the data inside of the union, you can use a switch with a <em>capture</em>, like so.
+</p>
+
+<pre class="hljs"><code class="language-onyx">
+main :: () {
+    value := MultipleTypes.{ string="Tagged unions are cool!" };
+
+    switch value {
+        case .int => int_value do printf("It was an integer: {}\n", int_value);
+
+        case .float => float_value do println("It was a float: {}\n", float_value);
+
+        // You can also use it by pointer by placing a '&' before the variable.
+        case .string => &str_value do println("It was a string: {}\n", *str_value);
+    }
+}
+</code></pre>
+
+<p>
+    You can also directly access the fields, like you would a structure.
+    However, instead of getting the data directly, you get an <em>Optional</em> of the data.
+    You then have to use the methods of the <em>Optional</em> type to access the data.
+</p>
+
+
+<pre class="hljs"><code class="language-onyx">MultipleTypes :: union {
+    int: i32;
+    float: f32;
+    string: str;
+}   
+
+main :: () {
+    v := MultipleTypes.{ float = 12.34 };
+    
+    // Using Optional.unwrap to get the data.
+    // This will cause an exception if the union does not currently hold a 'float'.
+    float_value := v.float->unwrap();
+    println(float_value);
+}
+</code></pre>
+
+<p>
+    Tagged unions can also be polymorphic, just like structures. With this feature, this is how the <code>Optional</code> type is now defined.
+</p>
+
+<pre class="hljs"><code class="language-onyx">Optional :: union (Value_Type: type_expr) {
+    None: void;
+    Some: Value_Type;
+}
+
+main :: () {
+    v := Optional(i32).{ Some = 123 };
+
+    switch v {
+        case .None {
+            println("No value :(");
+        }
+
+        case .Some => int_value {
+            printf("Int value: {}\n", int_value);
+        }
+    }
+}
+</code></pre>
+
+
+<h2>Full Changelog</h2>
+<pre>Additions:
+* Tagged unions (<code>union</code> type)
+* String literals can have unicode code points.
+    - '\uXXXX' for small code points (less than U+FFFF)
+    - '\UXXXXXX' for large code points
+    - Does not support UTF-16 surrogate pairs
+* <code>iter.next_opt</code>
+* <code>memory.ptr_add</code>
+* <code>misc.any_member</code>
+
+Removals:
+
+Changes:
+* <Code>optional</code> is now a tagged-union
+* <Code>result</code> is now a tagged-union
+* <code>iter.single</code> can take a <code>dispose</code> function, which is called on close of the
+    iterator, with the single value yielded.
+* <code>io.write_escaped_str</code> supports escaping "\\" now.
+* In Javascript runtime, made <code>__read_from_input</code> not defined right away, so
+    it can be overridden depending on the needs of the program.
+
+Bugfixes:
+* <code>json</code> encoder was wrongly not encoding strings when using <code>encode</code> on an <code>any</code>.
+</pre>
+
index 7c9ff3b582b7fff86ce65576427e3ac01546d2ea..6ca75369dee3962af76a849438a9213e347a9627 100644 (file)
@@ -158,6 +158,7 @@ h1, h2, h3, h4, h5, h6 {
 
 code {
     font-size: 0.9em;
+    font-family: fira, monospace;
 }
 
 
@@ -363,3 +364,7 @@ main li {
     }
 }
 
+@font-face {
+    font-family: fira;
+    src: url(../font/FiraCode-Regular.woff);
+}
diff --git a/www/static/font/FiraCode-Regular.woff b/www/static/font/FiraCode-Regular.woff
new file mode 100644 (file)
index 0000000..8816b69
Binary files /dev/null and b/www/static/font/FiraCode-Regular.woff differ