1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 22:31:12 +02:00

Changes from arch/CVS synchronization

This commit is contained in:
Ludovic Courtès 2007-06-13 22:20:39 +00:00
parent 5b0c950458
commit a944fd0f81
8 changed files with 65 additions and 27 deletions

View file

@ -1,3 +1,7 @@
2007-06-13 Ludovic Courtès <ludo@chbouib.org>
* NEWS: Mention top-level define incompatible change.
2007-06-12 Ludovic Courtès <ludo@chbouib.org>
* NEWS: Mention `inet-ntop' bug fix.

10
NEWS
View file

@ -12,6 +12,16 @@ Changes in 1.8.2 (since 1.8.1):
** set-program-arguments
** make-vtable
* Incompatible changes
** The body of a top-level `define' no longer sees the binding being created
In a top-level `define', the binding being created is no longer visible
from the `define' body. This breaks code like
"(define foo (begin (set! foo 1) (+ foo 1)))", where `foo' is now
unbound in the body. However, such code was not R5RS-compliant anyway,
per Section 5.2.1.
* Bugs fixed
** Fractions were not `equal?' if stored in unreduced form.

View file

@ -1,3 +1,9 @@
2007-06-13 Ludovic Courtès <ludo@chbouib.org>
* boot-9.scm (module-make-local-var!): Simplified. No need to
check for the value of a same-named imported binding since the
newly created variable is systematically assigned afterwards.
2007-01-04 Kevin Ryde <user42@zip.com.au>
* boot-9.scm (top-repl): Check (defined? 'SIGBUS) before using that

View file

@ -1515,19 +1515,10 @@
(module-modified m)
b)))
;; No local variable yet, so we need to create a new one. That
;; new variable is initialized with the old imported value of V,
;; if there is one.
(let ((imported-var (module-variable m v))
(local-var (or (and (module-binder m)
((module-binder m) m v #t))
(begin
(let ((answer (make-undefined-variable)))
(module-add! m v answer)
answer)))))
(if (and imported-var (not (variable-bound? local-var)))
(variable-set! local-var (variable-ref imported-var)))
local-var)))
;; Create a new local variable.
(let ((local-var (make-undefined-variable)))
(module-add! m v local-var)
local-var)))
;; module-ensure-local-variable! module symbol
;;

View file

@ -1,3 +1,9 @@
2007-06-13 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-06-12 Ludovic Courtès <ludo@chbouib.org>
* socket.c (scm_inet_ntop): In the `AF_INET' case, declare `addr4'

View file

@ -1213,10 +1213,11 @@ canonicalize_define (const SCM expr)
return expr;
}
/* 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)
* operation. This means, that within the expression we may already assign
* values to variable: (define foo (begin (set! foo 1) (+ foo 1))) */
/* 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)'
operation. However, EXPRESSION _can_ be evaluated before VARIABLE is
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_m_define (SCM expr, SCM env)
{
@ -1226,9 +1227,9 @@ scm_m_define (SCM expr, SCM env)
const SCM canonical_definition = canonicalize_define (expr);
const SCM cdr_canonical_definition = SCM_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
= 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)
{

View file

@ -1,3 +1,11 @@
2007-06-13 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-06-12 Ludovic Courtès <ludo@chbouib.org>
* tests/socket.test: Renamed module to `(test-suite test-socket)'.

View file

@ -725,15 +725,16 @@
(with-test-prefix "top-level define"
(pass-if "binding is created before expression is evaluated"
(= (eval '(begin
(define foo
(begin
(set! foo 1)
(+ foo 1)))
foo)
(interaction-environment))
2))
(pass-if "redefinition"
(let ((m (make-module)))
(beautify-user-module! m)
;; The previous value of `round' must still be visible at the time the
;; new `round' is defined. According to R5RS (Section 5.2.1), `define'
;; should behave like `set!' in this case (except that in the case of
;; Guile, we respect module boundaries).
(eval '(define round round) m)
(eq? (module-ref m 'round) round)))
(with-test-prefix "currying"
@ -780,6 +781,17 @@
(eq? 'c (a 2) (a 5))))
(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"
(false-if-exception
(eval '(let ((a identity) (b identity) (c identity))