From 17f69326e2b841d08543473eed9818e95f1f5f72 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Mon, 8 Jun 2020 22:58:30 +0200 Subject: [PATCH] Reverse order of a list initialized with M_LET to match the behavior of array --- m-core.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/m-core.h b/m-core.h index 48664eca..7e33b2c9 100644 --- a/m-core.h +++ b/m-core.h @@ -2666,10 +2666,15 @@ m_core_hash (const void *str, size_t length) /* Initialize the container 'dest' as per 'oplist' - and fill it with the given VA arguments */ + and fill it with the given VA arguments. + NOTE: If the REVERSE operator exists, it is a list, + so reverse the final order. +*/ #define M_INIT_VAI(oplist, dest, ...) \ (void)(M_GET_INIT oplist (dest) , \ - M_MAP2_C(M_INIT_VAI_FUNC, (dest, M_GET_PUSH oplist) , __VA_ARGS__)) + M_MAP2_C(M_INIT_VAI_FUNC, (dest, M_GET_PUSH oplist) , __VA_ARGS__) \ + M_IF_METHOD(REVERSE, oplist)(M_DEFERRED_COMMA M_GET_REVERSE oplist (dest), ) \ + ) #define M_INIT_VAI_FUNC(d, a) \ M_PAIR_2 d (M_PAIR_1 d, a)