Write Antril, run it in your browser and share it with a link. Programs are compiled to WebAssembly and run on your machine, not on the server.
Running programs is unavailable right now: the WebAssembly linker (wasm-ld, part of LLVM) is not installed on this server. You can still write, share and download code.
importSystem;
intonamespaceDestructors
{
classRes
{
i32 id;
public:
new(i32 id) { this.id = id; }
destroy() { Console.WriteLine($"destroy {id}"); }
}
Use(i32 id) : i32
{
Res r = newRes(id);
return id;
}
Main()
{
Use(1);
Console.WriteLine("after Use(1)");
region
{
Res inside = newRes(2);
Console.WriteLine("leaving the region");
}
Console.WriteLine("after the region");
GC.Collect();
Res filler = newRes(3);
Console.WriteLine($"collections: {GC.CollectionCount()}");
unsafe { delete filler; }
Console.WriteLine("end of Main");
}
}
Output
Press Run (or Ctrl+Enter) to compile and run the program.
Input
What Console.ReadLine() reads, one line at a time.
Ctrl+Enter runs. Tab indents (Shift+Tab outdents); press Esc, then Tab, to leave the editor. A program may run for 10 seconds.