Standard Docs
Documentation For Every Feature
obj
Create a named variable with a value.
// obj [name] = [value]
obj example_1 = "Whoa, this is a variable!";
obj example_2 = 10;
The value of an object can also be modified by shadowing its name.
obj x = 10;
obj x = 20; // x is now 20
fetch
Import an external .maid module.
fetch "path/to/my/module.maid";
my_modules_function();
Maid includes basic module functionality using the fetch keyword.
To use the fetch keyword, provide the module name (file name)
fetch std_math;
serve(math_pi); // object defined in the math module
Upon importing, objects are only appended to the current scope.
func i() {
fetch std_math;
}
i();
serve(math_pi); // we cant access this
sweep
Use sweep to read or extract data from a file and store its contents into a variable.
sweep log_data from "server.log";
serve(log_data);
sweep is used to load the contents of a file into a variable. It allows your program to process text, data, or logs from external sources.
sweep config from "settings.cfg";
func display() {
serve(config);
}
process
Use process to transform or analyze data that you've loaded or defined. It’s like parsing through the contents.
sweep raw_text from "essay.txt";
process cleaned_text from raw_text using strip_whitespace;
serve(cleaned_text);
You can also chain multiple transformations:
sweep csv_data from "grades.csv";
process parsed from csv_data using parse_csv;
process averages from parsed using compute_averages;
serve(averages);
stash
Use stash to store a value into a variable or persist data for future use.
stash name as "darling";
serve(name); // outputs: darling
serve
Use serve to display values, debug output, or return results.
func add(x, y) {
serve(x + y);
}
add(3, 4); // outputs: 7
walk
A loop running iterator 'x' length 'n' through 'n'. Programmers will be familiar with the for loop. This is the same thing! I like to imagine it as a walkthrough for beginner programmers!
walk i = 0 through 10 {
serve(i); # 'i' will be printed 10 times each incremented by one step (0, 1, 2, ... 9)
}
Optionally, add the step keyword to determine the amount 'x' is incremented by.
walk i = 0 through 10 step = 2 {
serve(i); # 'i' will be printed 5 times each incremented by two values (0, 2, 4, 6, 8)
}
func
A function or function object.
func example(arg1, arg2) { // as many args as you like!
serve("arg1: " + tostring(arg1));
serve("arg2: " + tostring(arg2));
}
example(1, 2); // call the function
Functions can also be assigned to objects.
func example(arg1, arg2) {
serve("arg1: " + tostring(arg1));
serve("arg2: " + tostring(arg2));
}
obj function = example;
function(1, 2); // call the function as the object name
Anonymous functions are used in pair with objects.
obj anonymous = func (value) { # no name 😱
serve(value);
};
anonymous("Maid");
alsoif
Execute code if another condition is met (used in chain with if statements.)
obj x = tonumber(process("Enter a number: "));
if x == 1 {
serve("x is 1, please guess higher.");
} alsoif x == 10 {
serve("x is correct! you win!");
} otherwise {
serve("oof. try again.");
}
otherwise
Used as the default interrupt of an if statement.
if 1 == 2 { // this condition is not true, so the otherwise block will be executed
serve("math broke!");
} otherwise {
serve("all systems working as usual");
}
while
A loop running while a condition is true.
while true {
serve("oh no! this loop runs infinitely!!");
}
unsafe
Represents the "try" case of a try/except expression. Used in chain with the safe keyword.
unsafe {
// dangerous code
} safe _ {
// ...
}
safe
Represents the "except" case of a try/except expression.
unsafe {
// ...
} safe error { // 'error' is an identifier containing the error as a string
# code that is executed if 'unsafe' block fails
}
give
Return a value from a statement.
func example() {
give true;
}
serve(example()); # 'true' is the return value
next
Skip to the next iteration of a walk or while loop.
walk i = 0 through 10 {
if i == 5 {
next; # skips to the next iteration
}
}
// 'next' can also be used on while loops
while true {
serve("This loop is ran infinitely!!");
next;
}
leave
Stop a walk or while loop.
walk i = 0 through 10 {
if i == 5 {
break; // stops the loop entirely and exits
}
}
// 'leave' can also be used on while loops
while true {
serve("This loop is only ran once");
break;
}
true
Number type representing true (1)
obj condition = true;
serve(condition); # outputs '1' because the true value is represented as 1
false
Number type representing false (0)
obj condition = false;
serve(condition); # outputs '0' because the false value is represented as 0
null
Number type representing null or "nothing" (0)
obj nothing = null;
serve(nothing); # outputs '0' because the null value is represented as 0
Since the null value is technically a boolean, boolean operations can be performed on null.
serve(not null); # true!
and
Compare two values added by each other.
serve(1 == 1 and 2 == 2); # true!
or
Compare two values ored by each other.
serve(1 == 1 or 2 == 2); # true!
not
Way to "not" a value (commonly used in boolean operations.)
serve(not true); # false!