mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
19 lines
307 B
C
19 lines
307 B
C
module test;
|
|
|
|
|
|
public macro retry(#function, int retries = 3)
|
|
{
|
|
error e;
|
|
while (1)
|
|
{
|
|
auto! result = #function;
|
|
try (result) return result;
|
|
catch (e = result);
|
|
} while (retries-- > 0)
|
|
return e!;
|
|
}
|
|
|
|
fn void main()
|
|
{
|
|
int! result = @retry(eventually_succeed());
|
|
} |