Added a couple of examples to the Readme and kind of got sidetracked exploring some Wormrote sigils for the language name lol
Ok I think I found a good name for my programming language. It's short and sweet and I haven't seen it used anywhere for other PL projects:
The Oni programming language
Named after the evil japanese yokai. Seems in-theme with the previous "badlang" name.
I've acquired oni-lang.com and will be updating my repos to use the new name soon. Perhaps this is a good opportunity to start adding a website and documentation.
Without too much trouble I managed to run Badlang code on the Playdate. Just had to override the panic function to use the pd system log and to create some wrapper functions.
I also added a custom allocator, meaning I can use most of the relevant stuff from the standard library. Here is shown a directory list, a file being read (and the written) and timing information. Additionally I can draw using the system drawing functions (for text and sprites) and directly on the framebuffer (as seen on the grid behind).
Perhaps I’ll have a bit more fun with this soon :)
Started exploring Result::(Error, Val) types and implemented a `tryor` operator (??). The previous `try` operator (?) would unwrap or return the default zeroed value for the current function. With this new operator we can perform some extra action before returning and give our desired return type.
Equivalent to:
let a = funcall() ?? ret_expr
let a = {
let tmp = funcall()
if not tmp.ok() then return ret_expr
tmp.val()
}
Since `ret_expr` is an expression, you could log a message before returning or something like that.
Pretty happy with this approach, I don't like to just blindly propagate an error, it needs to get handled somewhere or transform across type boundaries, which this should be able to handle.
Back home. Been doing some light programming on the side, namely bugfixing, adding support for typed enums (still only integer types, but this way you can stuff enums into structs and arrays and control their size) and exploring adding type aliases.
My initial implementation is super simple, just literally an alias so any function that takes the original type would also take the alias and vice-versa. Starting adding a more complex implementation where aliases are new types that could be casted back and forth between the original and alias implementation. This would become a hard typecheck failure if an alias is used instead of the original type and would enable having specific methods for aliased types.
Unsure if the complexity is worth the cost for this particular feature. Thoughts?