From ssax-sxml-admin@lists.sourceforge.net Mon Nov 18 19:51:09 2002 Message-ID: <200211182048.gAIKmfaY032514@adric.fnmoc.navy.mil> To: ssax-sxml@lists.sourceforge.net From: oleg-at-pobox.com Subject: [ssax-sxml] SSAX updates; Makefile as a functional program List-Archive: X-Original-Date: Mon, 18 Nov 2002 12:48:41 -0800 (PST) Date: Mon, 18 Nov 2002 12:48:41 -0800 (PST) Status: OR [Discussion on SSAX updates elided] The start of the active update cycle required an upgrade in my testing framework. I run regression tests on four platforms (Gambit interpreter, Bigloo interpreter and compiler, SCM interpreter). I will also add Scheme48 interpreter and a Gauche interpreter. I have 13 validation targets (not all of them are relevant to SSAX/SXML). Some targets are platform specific, most others must be run for all platforms under test. Each target has a 'build list' -- a list of modules, or files, to build the target from. The exact meaning of building and importing varies greatly among the platforms: for example, for SCM you do scm -b -l $(LIBDIR)/myenv-scm.scm -l $(LIBDIR)/inc-file1.scm ... whereas for Bigloo you do bigloo -s -i -I $(LIBDIR) \ -eval '(module test \ (include "myenv-bigloo.scm") (include "inc-file1.scm")...)' Scheme48 and Gauche each require something altogether different. Furthermore, some platforms do not have to 'include' certain files because they support the corresponding features natively. My testing Makefile would have therefore a rule for each target for each platform. The sheer number of rules makes the maintenance untenable. Fortunately, GNU make has given me a better opportunity. It turns out, the language of GNU make is functional, complete with combinators (map and filter), applications and anonymous abstractions. That is correct, GNU make supports lambda-abstractions. You can see my resulting Makefile at http://okmij.org/ftp/Scheme/tests/Makefile The makefile has a 'function' for each platform, and a rule for each validation target. The latter specifies the build list, and is platform-independent. For example, vinput-parse: $(call make-$(PLATFORM),\ catch-error.scm util.scm look-for-str.scm input-parse.scm,\ $@) A platform-specific make-xxx function will create a command or commands to make that specific target. For example, make-scmi= scm -b -l $(LIBDIR)/myenv-scm.scm \ $(foreach file,$(1),-l $(LIBDIR)/$(file)) \ -l $(2).scm Compare that with (define make-scmi (lambda (arg1 arg2) `(scm -b -l ,(mks LIBDIR '/ 'myenv-scm.scm) ,@(map (lambda (file) `(-l ,(mks LIBDIR '/ file))) ,arg1) -l ,(mks arg2 '.scm)))) The correspondence is amazing. As in TeX, arguments of a lambda-abstraction are numbered. Assigning them meaningful names is possible. Makefile's foreach corresponds to Scheme's map.