mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 06:41:13 +02:00
Changes from arch/CVS synchronization
This commit is contained in:
parent
41185bfe2a
commit
3dcf33733c
4 changed files with 41 additions and 14 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2007-05-26 Ludovic Courtès <ludo@chbouib.org>
|
||||||
|
|
||||||
|
* eval.c (scm_m_define): Updated comment. Changed order for value
|
||||||
|
evaluation and `scm_sym2var ()' call, which is perfectly valid per
|
||||||
|
R5RS. This reverts the change dated 2004-04-22 by Dirk Herrmann.
|
||||||
|
|
||||||
2007-05-05 Ludovic Courtès <ludo@chbouib.org>
|
2007-05-05 Ludovic Courtès <ludo@chbouib.org>
|
||||||
|
|
||||||
Implemented lazy duplicate binding handling.
|
Implemented lazy duplicate binding handling.
|
||||||
|
|
|
@ -1209,10 +1209,11 @@ canonicalize_define (const SCM expr)
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* According to section 5.2.1 of R5RS we first have to make sure that the
|
/* According to Section 5.2.1 of R5RS we first have to make sure that the
|
||||||
* variable is bound, and then perform the (set! variable expression)
|
variable is bound, and then perform the `(set! variable expression)'
|
||||||
* operation. This means, that within the expression we may already assign
|
operation. However, EXPRESSION _can_ be evaluated before VARIABLE is
|
||||||
* values to variable: (define foo (begin (set! foo 1) (+ foo 1))) */
|
bound. This means that EXPRESSION won't necessarily be able to assign
|
||||||
|
values to VARIABLE as in `(define foo (begin (set! foo 1) (+ foo 1)))'. */
|
||||||
SCM
|
SCM
|
||||||
scm_m_define (SCM expr, SCM env)
|
scm_m_define (SCM expr, SCM env)
|
||||||
{
|
{
|
||||||
|
@ -1222,9 +1223,9 @@ scm_m_define (SCM expr, SCM env)
|
||||||
const SCM canonical_definition = canonicalize_define (expr);
|
const SCM canonical_definition = canonicalize_define (expr);
|
||||||
const SCM cdr_canonical_definition = SCM_CDR (canonical_definition);
|
const SCM cdr_canonical_definition = SCM_CDR (canonical_definition);
|
||||||
const SCM variable = SCM_CAR (cdr_canonical_definition);
|
const SCM variable = SCM_CAR (cdr_canonical_definition);
|
||||||
|
const SCM value = scm_eval_car (SCM_CDR (cdr_canonical_definition), env);
|
||||||
const SCM location
|
const SCM location
|
||||||
= scm_sym2var (variable, scm_env_top_level (env), SCM_BOOL_T);
|
= scm_sym2var (variable, scm_env_top_level (env), SCM_BOOL_T);
|
||||||
const SCM value = scm_eval_car (SCM_CDR (cdr_canonical_definition), env);
|
|
||||||
|
|
||||||
if (SCM_REC_PROCNAMES_P)
|
if (SCM_REC_PROCNAMES_P)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
2007-05-26 Ludovic Courtès <ludo@chbouib.org>
|
||||||
|
|
||||||
|
* tests/syntax.test (top-level define)[binding is created before
|
||||||
|
expression is evaluated]: Moved to "internal define", using `let'
|
||||||
|
instead of `begin'. The test was not necessarily valid for
|
||||||
|
top-level defines, according to Section 5.2.1 or R5RS.
|
||||||
|
[redefinition]: New.
|
||||||
|
|
||||||
2007-05-09 Ludovic Courtès <ludo@chbouib.org>
|
2007-05-09 Ludovic Courtès <ludo@chbouib.org>
|
||||||
|
|
||||||
* tests/srfi-19.test ((current-time time-tai) works): Use `time?'.
|
* tests/srfi-19.test ((current-time time-tai) works): Use `time?'.
|
||||||
|
|
|
@ -725,15 +725,16 @@
|
||||||
|
|
||||||
(with-test-prefix "top-level define"
|
(with-test-prefix "top-level define"
|
||||||
|
|
||||||
(pass-if "binding is created before expression is evaluated"
|
(pass-if "redefinition"
|
||||||
(= (eval '(begin
|
(let ((m (make-module)))
|
||||||
(define foo
|
(beautify-user-module! m)
|
||||||
(begin
|
|
||||||
(set! foo 1)
|
;; The previous value of `round' must still be visible at the time the
|
||||||
(+ foo 1)))
|
;; new `round' is defined. According to R5RS (Section 5.2.1), `define'
|
||||||
foo)
|
;; should behave like `set!' in this case (except that in the case of
|
||||||
(interaction-environment))
|
;; Guile, we respect module boundaries).
|
||||||
2))
|
(eval '(define round round) m)
|
||||||
|
(eq? (module-ref m 'round) round)))
|
||||||
|
|
||||||
(with-test-prefix "currying"
|
(with-test-prefix "currying"
|
||||||
|
|
||||||
|
@ -780,6 +781,17 @@
|
||||||
(eq? 'c (a 2) (a 5))))
|
(eq? 'c (a 2) (a 5))))
|
||||||
(interaction-environment)))
|
(interaction-environment)))
|
||||||
|
|
||||||
|
(pass-if "binding is created before expression is evaluated"
|
||||||
|
;; Internal defines are equivalent to `letrec' (R5RS, Section 5.2.2).
|
||||||
|
(= (eval '(let ()
|
||||||
|
(define foo
|
||||||
|
(begin
|
||||||
|
(set! foo 1)
|
||||||
|
(+ foo 1)))
|
||||||
|
foo)
|
||||||
|
(interaction-environment))
|
||||||
|
2))
|
||||||
|
|
||||||
(pass-if "internal defines with begin"
|
(pass-if "internal defines with begin"
|
||||||
(false-if-exception
|
(false-if-exception
|
||||||
(eval '(let ((a identity) (b identity) (c identity))
|
(eval '(let ((a identity) (b identity) (c identity))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue