Replies: 2 comments
-
Although the previous idea is possible and works. Im planning to implement a simpler system:
This expects the identifier Usage: This might be even beter:
|
Beta Was this translation helpful? Give feedback.
-
Macros have been implemented as follow: macro array {
input {
"[]" type;
"{}" values @repeat;
}
output {
"@value {\n"
"let array = Array[%type].new();\n"
"array.push(%values);\n"
"return array;\n"
"}"
}
} Usage: |
Beta Was this translation helpful? Give feedback.
-
Allow every package (that includes your own project), to make a
macro.ki
file in the root of the package. This will pre-compiled by the compiler and loaded in, so that the compiler can use it to generate code. Much likevec!
in rust.The reason being, right now im thinking about adding shortcuts for arrays and maps. And i could do that in the compiler, but i feel like the user should also be able to define such shortcuts.
Example:
The "[]" defines the code start/end characters. You can only choose between: "[]", "()" and "{}".
Usage:
.arr[String, "Hello", "World"];
The macro would be enclosed inside it's own scope, so we can declare variables without conflict.
Beta Was this translation helpful? Give feedback.
All reactions