Quark 0.5 Pre-release
Pre-releaseQuark 0.5 Pre-release Changlog
- Major changes to the generics system for improved type following
- New module system instead of the previous
#include-like system - Partial support for function lambdas and function types
- Unused declarations no longer compile, giving you a smaller output file without redundant symbols
Generics Changes
Although a lot has changed behind to scenes to make generics more smooth to write, no syntactical changes have been made. The next big change to generics would be in the form of generics operators #35, but this feature may not be implemented in the first 0.5.0 full release.
Generics were split into left and right so binary operations can no longer have mismatching generics metadata when types are being matched together. Much of the logic for autos has also be slightly reworked to simplify the process and make it easier to debug.
Module System
Important
Due to the changes with the module system, the $QUARK_ROOT/$QUARK_LIB has changed from the root of the cloned repo to lib/. (use -l $QUARK_LIB)
# New .basrch or .zshrc
export QUARK_ROOT="/aboslute/path/to/SDK/quark"
export QUARK_LIB="$QUARK_ROOT/lib"
export PATH="$PATH:$QUARK_ROOT"Quark now tracks modules and relative file paths instead of copy and pasting source files into the parser. Along with the reworked import statement, there is now the private keyword which currently only works on function and variable declarations to make them file specific.
To demonstrate the changes, lets say we have a file layout like this, where utils is a folder and the entry point is main.qk:
# utils
\_ * math.qk
* print.qk
* main.qk
We can start by creating a hello() function in print.qk,
// print.qk
void hello() {
print("Hello World!");
}We can import the print module strait from the entry file without any configuration:
// main.qk
import print;
print::hello(); // Hello World!Similarly, you can import a file within a folder. I'll make an add() function to demonstrate this
// utils/math.qk
i32 add(i32 a, i32 b) {
return a + b;
}// main.qk
import utils::math;
i32 sum = math:add(3, 4); // 7In import statements, you can also specify which functions to import, or all using a wildcard,
// main.qk
import print::{ hello };
import utils::math::*;Functions can be specified as private using the private keyword. Note that regular imports and selective imports using curly brackets are private by default while wildcard imports are public.
// This function cannot be used outside of its enclosing file
private str get_password() {
return "MyP4s5w0rd!";
}Function Types and Lambdas
Quark now has better support for compiling function types and allows you to specify them using a nameless function with nameless arguments,
i32 (i32, i32) sum_function = /* ... */;You can specify a lambda in the same way using argument names and a => or {:
auto sum = i32 (i32 a, i32 b) => a + b;
auto say_hello = void () {
print("Hello!");
}Its important to note that, at their current stage, function lambdas cannot access external context,
void () curry(i32 number) {
return void () {
print_i32(number); // will not work
}
}Fixes
0.5.1preAn issue with modules using their reference in a volatile vector structure has been fixed, this issue may have made it impossible to run the compiler.0.5.2preFixed an issue where using types that are in different structure declarations would generate a false non-trait error.0.5.3preFixed function type declaration order (section 1 to section 0)0.5.4preFixed a couple of seg-faults caused by error paths, fixed an issue where some structures wouldn't produce their declarations, and fixed the>>token not working in generics.0.5.5preNew structure parser and complete support forprivatefields. Partial support forstatickeyword in structs.
Extra
Full Diff: 0.4.1...0.5.5pre