Memory

The kairo corelib contains std::create and std::forget (yes forget is not a good name, but it is what it is for now) for memory management. std::create is used to allocate memory for an object and return a reference to it, while std::forget is used to deallocate memory for an object that is no longer needed.

fn main() {
    // Allocate memory for an integer
    var my_int: *i32 = std::create::<i32>(42);
    std::print(f"My integer: {my_int}");

    // Deallocate memory for the integer
    std::forget(my_int);

    // Allocate memory for a string
    var my_string: *string = std::create::<string>("Hello, Kairo!");
    std::print(f"My string: {*my_string}");

    // Deallocate memory for the string
    std::forget(my_string);

    /// nullptr example
    var my_null: *i32 = &null;
    if (my_null == &null) {
        std::print("my_null is a null pointer");
    }
}