summaryrefslogtreecommitdiff
path: root/modules/language/python/compile.scm
diff options
context:
space:
mode:
Diffstat (limited to 'modules/language/python/compile.scm')
-rw-r--r--modules/language/python/compile.scm13
1 files changed, 12 insertions, 1 deletions
diff --git a/modules/language/python/compile.scm b/modules/language/python/compile.scm
index 7585a15..49c6a64 100644
--- a/modules/language/python/compile.scm
+++ b/modules/language/python/compile.scm
@@ -14,6 +14,7 @@
#:use-module (language python bytes)
#:use-module (language python number)
#:use-module (language python def)
+ #:use-module ((language python with) #:select ())
#:use-module (ice-9 pretty-print)
#:export (comp))
@@ -35,6 +36,7 @@
(define-inlinable (O x) `(@@ (oop pf-objects) ,x))
(define-inlinable (G x) `(@ (guile) ,x))
(define-inlinable (H x) `(@ (language python hash) ,x))
+(define-inlinable (W x) `(@ (language python with) ,x))
(define s/d 'set!)
@@ -706,7 +708,16 @@
(fin (get-addings vs (list fin)))
(f (exp vs base)))
`(,(C 'del-x) (,(C 'ref-x) ,f ,@add) ,@fin))))
-
+
+ (#:with
+ ((_ (l ...) code)
+ (let ((l (map (lambda (x)
+ (match x
+ ((a b) (list (exp vs a) (exp vs b)))
+ ((b) (list (exp vs b)))))
+ l)))
+ `(,(W 'with) ,l ,(exp vs code)))))
+
(#:if
((_ test a ((tests . as) ...) . else)
`(,(G 'cond)