diff --git a/posts/2020-08-20-the-onyx-programming-language.md b/posts/2020-08-20-the-onyx-programming-language.md index 5297814..ff2d0b4 100644 --- a/posts/2020-08-20-the-onyx-programming-language.md +++ b/posts/2020-08-20-the-onyx-programming-language.md @@ -81,6 +81,7 @@ This is a very basic program written in Onyx: ```text import "stdio.h" +# Outputs "Hello, world!" export int main() { final msg = "Hello, world!\0" unsafe! $puts(&msg as $char*) @@ -100,6 +101,7 @@ Imported entities are referenced with preceding `$` symbol to distinguish them f The `final` statement defines a constant named `msg`. The type of `msg` is inferred to be `String`, i.e. a [UTF-8](https://en.wikipedia.org/wiki/UTF-8)-encoded array of [code units](https://en.wikipedia.org/wiki/Code_unit) containing 14 elements. +Note that this is not a pointer, but a real array, probably allocated on stack. Then, the address of the `msg` constant is taken. The resulting object of taking an address would be `String*lr0`, which is a shortcut to `Pointer, Scope: :local, Readable: true, Writeable: false, Space: 0>`. @@ -122,7 +124,7 @@ But in return, it makes the emitted code predictable and portable. #### Using a standard library -An Onyx compiler is not required to implement any sort of OS-specific standard library. +An Onyx compiler is not required to implement any sort of OS-dependent standard library. Instead, the standard library Standard is specified elsewhere (spoiler alert: by [the Onyx Software Foundation](#the-onyx-software-foundation)). A standard library ought to be used as a typical package and required like any other from your code. @@ -145,9 +147,10 @@ export void main() { ``` Now, the code is perfectly safe. -Even passing of `&msg` is allowed, because `Std.puts` has an overload accepting a `String*cr`, i.e. a read-only pointer with _caller_ scope, and a pointer with _local_ scope may be safely cast to _caller_ scope upon passing to a function! +Even passing of `&msg` is allowed, because `Std.puts` has an overload accepting a `String*cr`, i.e. a read-only pointer with _caller_ scope, and a pointer with _local_ scope may be safely cast to _caller_ scope upon passing to a function. +This is where the full power of pointer scope harnesses! -Also note that `msg` is now a variable, as it is defined with `let` statement. +Also note that `msg` is now a **variable** instead of a constant, as it is defined with `let` statement. Taking the address of `msg` would return `String*lrw0`. Notice the `w` part? The pointer is now writeable. @@ -160,7 +163,7 @@ The cause is that an `export`ed function must guarantee never to throw an except The `Std.exit` function is declared as `nothrow`, so we can leave it as-is. But what if we wanted to inspect the backtrace of the possible exception? -Well, the language Standard states that a backtrace object must implement `Endful` trait. +Well, the language Standard states that a backtrace object must implement the `Endful` trait. This is truncated source code of the trait: ```text @@ -178,7 +181,7 @@ end Let's implement some `Stack` type to hold the backtrace. -::: spoiler ⚠️ A big chunk of code! +::: spoiler ⚠️ A big chunk of non-trivial code! ```text # A stack growing upwards in memory. @@ -352,7 +355,8 @@ export int main () { while final loc = backtrace.pop?() Std.cout << "At " << loc.path << ":" << - loc.row << ":" << "\n" + loc.row << ":" << + loc.col << "\n" end Std.exit(1) @@ -516,7 +520,7 @@ require "gen_class" @gen_class("user") ``` -Which would result in: +Which would possibly result in: ```text require "gen_class" @@ -535,6 +539,7 @@ end ::: +Nuff said. For example: ```text @@ -594,12 +599,12 @@ reopen Int<Base: 2, Signed: S, Size: Z> forall S, Z end ``` -This is a fairly complex example making use of inline assembly feature. +This is a fairly complex example making use of the inline assembly feature. But this is what the language is capable of. Notice that delayed macro blocks, i.e. those beginning with `{{`, are evaluated on every specialization, so the contents of the `add` function would be different for `Int` (a.k.a. `SBin16`) and `Int` (a.k.a. `UBin32`). -There were other features of Onyx mentioned in the example: 1) reopening certain, even broad (the `forall` thing), specializations, 2) and aliasing. +There were other features of Onyx mentioned in the example: 1) reopening certain or broad (the `forall` thing), specializations, 2) aliasing. In fact, this is how integer aliasing looks like in the Core API: ```text @@ -801,7 +806,7 @@ Apart from funding packages, the Foundation will sponsor projects and events rel Onyx is the perfect balance between productivity and performance, a language understandable well both by humans and machines. Thanks to powerful abstraction mechanisms and inference, the areas of the appliance are truly endless. -I heartfully believe that Onyx may be that new lingua franca for decades until humanity learns to transfer thoughts directly into machines. +I heartfully believe that Onyx may become a new lingua franca for decades until humanity learns to transfer thoughts directly into machines. Visit [nxsf.org](https://nxsf.org) to stay updated, and... diff --git a/posts/2020-08-27-sponsoring-onyx.md b/posts/2020-08-27-sponsoring-onyx.md index 8ae512f..b8aa44f 100644 --- a/posts/2020-08-27-sponsoring-onyx.md +++ b/posts/2020-08-27-sponsoring-onyx.md @@ -7,7 +7,7 @@ ogType: article --- Standardizing and implementing a system programming language is hard, but you can help! -Find out how you can sponsor the future, and many hours does it take to create a language mascot, in this post. +Find out how you can sponsor the future, and how many hours does it take to create a language mascot, in this post.

TL; DR;

@@ -32,7 +32,7 @@ By the way, I assume you've read my recent [post on System Programming](/posts/2 ## Deeds Already Done -The onyxlang.com domain name was registered on June 20^th^ 2019. +The onyxlang.org domain name was registered on June 20^th^ 2019. As I have a sin of registering domains as soon as I have a solid idea, the day may be treated as the Onyx birthday. Today is August 27^th^ 2020, and I've already spent a plethora of time on Onyx. @@ -134,7 +134,7 @@ Nothing is publicly stable, work-in-progress etcetera. Note that theoretically I could've tried applying to Open Collective right now, but: - 1. It implies free-will donations, but what I'm proposing here is clearly purchase of placement in history; + 1. It implies free-will donations, but what I'm proposing here is clearly a purchase; 1. I don't think Onyx is currently "popular" enough; @@ -149,7 +149,7 @@ And as I haven't got a real job for a long, long time, my financial cushion is r As a copyright holder, I'm planning on licensing the Onyx Standard Specification and auxiliary standards with a free, open-source license requiring attribution. -Therefore, I can offer you, a potential sponsor, a **perpetual**\* attribution in the standards I'll be working on during the pre-alpha development stage. +Therefore, I can offer you, a potential sponsor, a **perpetual**\* attribution in the standards I'll be working on during the pre-alpha development stage. Your name or company logo with an optional link would be put into according "early contributors" sections of the standards. \* As long as my attribution is required.