From 6b6d7156538c6e22669d8073c3b89561dc72eb1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Mon, 28 Jul 2025 20:04:15 +0500 Subject: [PATCH] Add Var and VarThrows --- include/with99.h | 2 +- include/with99/defres.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/with99.h b/include/with99.h index f9c19c3..7f51bdc 100644 --- a/include/with99.h +++ b/include/with99.h @@ -14,7 +14,7 @@ #endif #define WITH99_MAJOR 3 -#define WITH99_MINOR 0 +#define WITH99_MINOR 1 #define WITH99_PATCH 0 #define WITH99_VERSION_COMPATIBLE(x, y, z) (WITH99_MAJOR == (x) && ((WITH99_MINOR == (y) && WITH99_PATCH >= (z)) || (WITH99_MINOR > (y)))) diff --git a/include/with99/defres.h b/include/with99/defres.h index c49052f..7cdd9bb 100644 --- a/include/with99/defres.h +++ b/include/with99/defres.h @@ -15,6 +15,20 @@ ML99_just(v((deinit)))\ ) +#define WITH99_resource_Var_IMPL(type, var, init, deinit) \ + ML99_tuple(\ + ML99_just(v(type var)),\ + ML99_just(v(((var = init), 1))),\ + ML99_just(v((deinit)))\ + ) + +#define WITH99_resource_VarThrows_IMPL(type, var, init, deinit, errorvalue) \ + ML99_tuple(\ + ML99_just(v(type var)),\ + ML99_just(v( ((var = init), var != errorvalue) )),\ + ML99_just(v((deinit)))\ + ) + #define WITH99_resource_Call_IMPL(init, deinit) \ ML99_tuple(\ ML99_nothing(),\