mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
Issue #331 - Ensure map evaluates in order
Reverse so everything is evaluated in order, then reverse again so final results are in order.
This commit is contained in:
parent
7420b34f84
commit
f211d350e0
1 changed files with 11 additions and 6 deletions
|
@ -614,17 +614,22 @@
|
||||||
rename-env
|
rename-env
|
||||||
local-renamed))))))
|
local-renamed))))))
|
||||||
(cond
|
(cond
|
||||||
;; special case - a begin can splice in definitions, so we can't use the
|
;; special case - begin can splice in definitions, so we can't use the
|
||||||
;; built-in macro that just expands them in a new lambda scope. Instead
|
;; built-in macro that just expands them within a new lambda scope.
|
||||||
;; we nest them below within the same lexical environment.
|
;; Instead we nest them below within the same lexical environment.
|
||||||
((eq? 'begin op)
|
((eq? 'begin op)
|
||||||
;(newline)
|
;(newline)
|
||||||
;(display "/* ")
|
;(display "/* ")
|
||||||
;(write (list exp))
|
;(write (list exp))
|
||||||
;(display "*/ ")
|
;(display "*/ ")
|
||||||
(let ((fncs (map (lambda (expr)
|
(let ((fncs
|
||||||
(analyze expr a-env rename-env local-renamed))
|
;; Our map starts from the end, we reverse
|
||||||
(cdr exp))))
|
;; so everything is evaluated in order, then
|
||||||
|
;; reverse again so results are in order
|
||||||
|
(reverse
|
||||||
|
(map (lambda (expr)
|
||||||
|
(analyze expr a-env rename-env local-renamed))
|
||||||
|
(reverse (cdr exp))))))
|
||||||
(lambda (env)
|
(lambda (env)
|
||||||
(foldl (lambda (fnc _) (fnc env)) #f fncs))))
|
(foldl (lambda (fnc _) (fnc env)) #f fncs))))
|
||||||
;; compiled macro
|
;; compiled macro
|
||||||
|
|
Loading…
Add table
Reference in a new issue