`r`n`r`n `r`n

?? ?b? - Resource Lifecycle

RAII resource management inspired by Yoruba sacrifice traditions

What is ?b??

?b? (Yoruba: "sacrifice/offering") is Ifá-Lang's resource lifecycle system. It ensures cleanup code runs automatically when resources go out of scope — similar to Rust's RAII, Go's defer, or C++ destructors.

??? Ebo Guard

Zero-cost RAII guard that runs cleanup on drop

?? EboScope

Wraps a resource with automatic cleanup

? defer!

Go-style defer for end-of-scope cleanup

Basic Usage

ebo "resource";

Declare a resource lifecycle. Cleanup runs when the scope ends.

// Open a file with automatic cleanup
ebo "tempfile";
ayanmo file = Odi.write("temp.txt", "data");

// When scope ends, resource is cleaned up automatically

Ebo Guard (Rust API)

Ebo::new(name, cleanup)

Create a guard that runs cleanup when dropped.

// Create RAII guard
ayanmo guard = Ebo.new("db_connection", || {
    db.close();
});

// Do work with database...

// Cleanup runs automatically when guard drops

guard.dismiss()

Cancel cleanup — resource will NOT be cleaned up.

ayanmo guard = Ebo.new("lock", || release_lock());

// Decide to keep the lock
guard.dismiss();  // Cleanup cancelled

guard.sacrifice()

Run cleanup early, then dismiss the guard.

ayanmo guard = Ebo.new("cache", || cache.flush());

// Force early cleanup
guard.sacrifice();  // Runs immediately, not on scope exit

EboScope (Scoped Resources)

EboScope::new(value, cleanup)

Wrap a value with automatic cleanup when scope ends.

// Scoped file handle
ayanmo scoped = EboScope.new(
    Odi.open("data.txt"),
    |file| file.sync()  // Cleanup: sync before close
);

// Use the file
scoped.write("Hello");

// sync() called automatically when scoped drops

scoped.into_inner()

Extract the value, running cleanup first.

ayanmo scoped = EboScope.new(42, |n| Irosu.fo("Cleaned: " + n));
ayanmo value = scoped.into_inner();  // Prints "Cleaned: 42"

scoped.leak()

Extract value WITHOUT running cleanup.

ayanmo scoped = EboScope.new(resource, |r| r.close());
ayanmo leaked = scoped.leak();  // No cleanup runs

defer! Macro (Go-style)

defer!(cleanup)

Run cleanup at end of current scope (like Go's defer).

ise process() {
    defer!(|| Irosu.fo("Done processing"));
    
    // Do work...
    Irosu.fo("Working...");
    
    // "Done processing" printed when function returns
}

Use Cases