A elegant and modern systems programming language
This style guide outlines conventions and best practices for writing Lotus code. Following these guidelines ensures consistent, readable, and maintainable code across the Lotus ecosystem.
a = b + cfunc(a, b, c)func(x) not func ( x )if x: { ... }user_count, max_valueMAX_SIZE, DEFAULT_TIMEOUTcalculate_total(), process_data()get_value(), set_color()is_ or has_: is_empty(), has_error()Person, DatabaseConnection// for inline comments/* */ for block comments// Calculate factorial of n
// Parameters: n (int) - non-negative integer
// Returns: int - factorial of n
fn int factorial(int n) {
if n <= 1: {
ret 1;
}
ret n * factorial(n - 1);
}
if x > 10: {
printf("x is large\n");
}
if condition1 && condition2 &&
condition3: {
// Handle case
}
for loops for iteration with known countwhile loops for conditional iterationfn int add(int a, int b) {
ret a + b;
}
fn void process_data(int count,
int max_size) {
// Implementation
}
malloc() for dynamic allocationfree() to release memoryint* data = malloc(100 * sizeof(int));
if data: {
// Use data
free(data);
}
%d for integers%s for strings%c for characters\n%d - decimal integer%x - hexadecimal (lowercase)%X - hexadecimal (uppercase)%o - octal%b - binary%s - string%c - character%v - generic valueint value = 42;
printf("The answer is %d\n", value);
printf("Hex: %x, Oct: %o\n", value, value);
printf("String: %s\n", "hello world");
Before submitting code, verify: