aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-10-09 13:47:36 +0100
committerArun Isaac2023-10-09 14:50:51 +0100
commit548cc54bc27b92c3a35a79d1af7440fbad896752 (patch)
tree759b53c95f871451a77e37d8403444041051eb57
parent3e8dac4240eb1f3abe46ce0efac83a97283b8fcc (diff)
downloadccwl-548cc54bc27b92c3a35a79d1af7440fbad896752.tar.gz
ccwl-548cc54bc27b92c3a35a79d1af7440fbad896752.tar.lz
ccwl-548cc54bc27b92c3a35a79d1af7440fbad896752.zip
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.
-rw-r--r--ccwl/ccwl.scm12
-rw-r--r--tests/ccwl.scm6
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 <cwl-workflow> 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")