Issue #489 - Guarantee order of eval begin exprs

Guarantee that sub-expressions of a begin are evaluated in order. The code was reversing the results of a map. However map is not necessarily guaranteed to evaluate its arguments in any given order because it could be optimized into another function such as `Cyc-map-loop-1`. Instead we just use the optimized function directly as a more general `map` is not required here and this function is guaranteed to process its argument list in a predicable order.
This commit is contained in:
Justin Ethier 2022-07-21 21:41:47 -04:00
parent 1506f0985f
commit f8555f796d
2 changed files with 7 additions and 8 deletions

View file

@ -9,6 +9,10 @@ Features
Bug Fixes
- Prevent an error when evaluating a `begin` expression that contains both a macro definition and an application of that macro. For example:
begin (define-syntax foo (syntax-rules () ((foo) 123))) (foo))
- Fix a regression where `c-compiler-options` was not recognized as a top level form by programs.
- Enforce a maximum recursion depth when printing an object via `display` and `write`, and when comparing objects via `equal?`. This prevents segmentation faults when working with circular data structures.

View file

@ -636,14 +636,9 @@
;(display "/* ")
;(write (list exp))
;(display "*/ ")
(let ((fncs
;; Our map starts from the end, we reverse
;; 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))))))
(let ((fncs (Cyc-map-loop-1 (lambda (expr)
(analyze expr a-env rename-env local-renamed))
(cdr exp))))
(lambda (env)
(foldl (lambda (fnc _) (fnc env)) #f fncs))))
;; compiled macro