`r`n`r`n
`r`nRAII resource management inspired by Yoruba sacrifice traditions
?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.
Zero-cost RAII guard that runs cleanup on drop
Wraps a resource with automatic cleanup
Go-style defer for end-of-scope cleanup
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
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
Cancel cleanup — resource will NOT be cleaned up.
ayanmo guard = Ebo.new("lock", || release_lock());
// Decide to keep the lock
guard.dismiss(); // Cleanup cancelled
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
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
Extract the value, running cleanup first.
ayanmo scoped = EboScope.new(42, |n| Irosu.fo("Cleaned: " + n));
ayanmo value = scoped.into_inner(); // Prints "Cleaned: 42"
Extract value WITHOUT running cleanup.
ayanmo scoped = EboScope.new(resource, |r| r.close());
ayanmo leaked = scoped.leak(); // No cleanup runs
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
}