mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-18 21:29:18 +02:00
Merge pull request #539 from justinethier/issue-537-apply-in-icyc
Issue 537 apply in icyc
This commit is contained in:
commit
645683937f
2 changed files with 13 additions and 3 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
Bug Fixes
|
||||
|
||||
- Fixed a bug in `apply` where an error may be raised when processing quoted sub-expressions. For example the following would throw an error: `(apply cons '(5 (1 2)))`. Thanks to @srgx for the bug report!
|
||||
- Fixed a beta expansion optimization bug where code such as the following would cause the compiler to hang. Thanks to Yorick Hardy for the bug report:
|
||||
|
||||
(define (compile-forever x) x (compile-forever x))
|
||||
|
|
|
@ -89,17 +89,26 @@
|
|||
((analyze exp *global-environment* rename-env '()) *global-environment*)
|
||||
((analyze exp (car env) rename-env '()) (car env))))
|
||||
|
||||
;; Called from the C runtime to support apply
|
||||
(define (eval-from-c exp . _env)
|
||||
(let ((env (if (null? _env) *global-environment* (car _env))))
|
||||
(eval (wrapc exp) env)))
|
||||
|
||||
;; Expressions received from C code are already evaluated, but sometimes too much so.
|
||||
;; Try to wrap
|
||||
;; Helper function for eval-from-c
|
||||
;;
|
||||
;; Expressions received from C code are already evaluated,
|
||||
;; however any quoted expressions will have the quotes
|
||||
;; stripped off. This is a problem for expressions that
|
||||
;; aren't self evaluating - like (1 2) - so we re-quote
|
||||
;; the expressions here so a subsequent eval will work.
|
||||
;;
|
||||
(define (wrapc exp)
|
||||
(cond
|
||||
((application? exp)
|
||||
(cond
|
||||
((compound-procedure? (car exp))
|
||||
((or (primitive-procedure? (car exp))
|
||||
(compound-procedure? (car exp))
|
||||
(procedure? (car exp)))
|
||||
(cons
|
||||
(car exp)
|
||||
(map
|
||||
|
|
Loading…
Add table
Reference in a new issue