From e53dc269a372cbcc678f7ac49bce4ee5f2ac4c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pottier?= Date: Thu, 16 Feb 2017 16:15:45 +0100 Subject: [PATCH] Define [fa] using [iter] instead of [reduce]. --- src/AlphaLibMacros.cppo.ml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/AlphaLibMacros.cppo.ml b/src/AlphaLibMacros.cppo.ml index 3ce86cf..c627731 100644 --- a/src/AlphaLibMacros.cppo.ml +++ b/src/AlphaLibMacros.cppo.ml @@ -7,6 +7,8 @@ (* -------------------------------------------------------------------------- *) +(* [fa] could be defined in terms of [reduce], as follows. *) + #define FA_CLASS __fa #define FA_FUN(term) CONCAT(fa_, term) @@ -20,6 +22,26 @@ let FA_FUN(term) t = \ new FA_CLASS # VISIT(term) () t \ +#undef __FA +#undef FA + +(* -------------------------------------------------------------------------- *) + +(* We prefer to define [fa] in terms of [iter] because we wish to eliminate + our dependency on [reduce] visitors. *) + +#define __FA \ + class FA_CLASS = object \ + inherit [_] iter \ + inherit [_] KitFa.iter \ + end \ + +#define FA(term) \ + let FA_FUN(term) t = \ + let o = new FA_CLASS in \ + o # VISIT(term) KitFa.empty t; \ + o # accu + (* -------------------------------------------------------------------------- *) #define FILTER_CLASS __filter -- GitLab