From 548cc54bc27b92c3a35a79d1af7440fbad896752 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 9 Oct 2023 13:47:36 +0100 Subject: ccwl: In macro expansion, use eval instead of module introspection. eval is not just more portable but also more flexible. It lets us allow steps with expressions that evaluate to commands. Sadly, we do not yet properly support commands defined in lexical scope. * ccwl/ccwl.scm (function-object): Use eval instead of module introspection. * tests/ccwl.scm ("allow steps with expressions that evaluate to commands"): New test. --- ccwl/ccwl.scm | 12 ++++++------ tests/ccwl.scm | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index 00d503f..b158947 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -412,12 +412,12 @@ object or a object." object) described by syntax X. If such a ccwl function is not defined, return #f." ;; TODO: What if function object is defined in lexical scope? - (let ((var (module-variable (current-module) - (syntax->datum x)))) - (and var - (or (command? (variable-ref var)) - (cwl-workflow? (variable-ref var))) - (variable-ref var)))) + (let ((result (false-if-exception + (eval (syntax->datum x) + (interaction-environment))))) + (and (or (command? result) + (cwl-workflow? result)) + result))) (define (collect-steps x input-keys) "Traverse ccwl workflow body X and return two values---a list of diff --git a/tests/ccwl.scm b/tests/ccwl.scm index 9aa00f3..2207200 100644 --- a/tests/ccwl.scm +++ b/tests/ccwl.scm @@ -139,4 +139,10 @@ (workflow () (print-with-default))) +(test-assert "allow steps with expressions that evaluate to commands" + (workflow ((message #:type string)) + ((and #t print) + (print) + #:message message))) + (test-end "ccwl") -- cgit v1.2.3