mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-11 22:31:12 +02:00
make-procedure-with-setter inherits name from getter
* libguile/procs.c (scm_make_procedure_with_setter): Patch through the getter's procedure name to the procedure-with-setter. Fixes part of the srfi-17 test, as the VM doesn't set procedure-name on define -- but perhaps that is the bug that should be fixed. In any case this patching is cheap. * test-suite/tests/eval.test: Change so that (define name pws) is initially passed an anonymous procedure-with-setter, as was the case before the procs.c change.
This commit is contained in:
parent
0a283d1b0b
commit
3fd8807eab
2 changed files with 24 additions and 5 deletions
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "libguile/validate.h"
|
#include "libguile/validate.h"
|
||||||
#include "libguile/procs.h"
|
#include "libguile/procs.h"
|
||||||
|
#include "libguile/procprop.h"
|
||||||
#include "libguile/programs.h"
|
#include "libguile/programs.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -300,11 +301,25 @@ SCM_DEFINE (scm_make_procedure_with_setter, "make-procedure-with-setter", 2, 0,
|
||||||
"with the associated setter @var{setter}.")
|
"with the associated setter @var{setter}.")
|
||||||
#define FUNC_NAME s_scm_make_procedure_with_setter
|
#define FUNC_NAME s_scm_make_procedure_with_setter
|
||||||
{
|
{
|
||||||
|
SCM name, ret;
|
||||||
SCM_VALIDATE_PROC (1, procedure);
|
SCM_VALIDATE_PROC (1, procedure);
|
||||||
SCM_VALIDATE_PROC (2, setter);
|
SCM_VALIDATE_PROC (2, setter);
|
||||||
return scm_double_cell (scm_tc7_pws,
|
ret = scm_double_cell (scm_tc7_pws,
|
||||||
SCM_UNPACK (procedure),
|
SCM_UNPACK (procedure),
|
||||||
SCM_UNPACK (setter), 0);
|
SCM_UNPACK (setter), 0);
|
||||||
|
/* don't use procedure_name, because don't care enough to do a reverse
|
||||||
|
lookup */
|
||||||
|
switch (SCM_TYP7 (procedure)) {
|
||||||
|
case scm_tcs_subrs:
|
||||||
|
name = SCM_SNAME (procedure);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
name = scm_procedure_property (procedure, scm_sym_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (scm_is_true (name))
|
||||||
|
scm_set_procedure_property_x (ret, scm_sym_name, name);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,11 @@
|
||||||
;;
|
;;
|
||||||
(define foo-closure (lambda () "hello"))
|
(define foo-closure (lambda () "hello"))
|
||||||
(define bar-closure foo-closure)
|
(define bar-closure foo-closure)
|
||||||
(define foo-pws (make-procedure-with-setter car set-car!))
|
;; make sure that make-procedure-with-setter returns an anonymous
|
||||||
|
;; procedure-with-setter by passing it an anonymous getter.
|
||||||
|
(define foo-pws (make-procedure-with-setter
|
||||||
|
(lambda (x) (car x))
|
||||||
|
(lambda (x y) (set-car! x y))))
|
||||||
(define bar-pws foo-pws)
|
(define bar-pws foo-pws)
|
||||||
|
|
||||||
(with-test-prefix "define set procedure-name"
|
(with-test-prefix "define set procedure-name"
|
||||||
|
@ -222,7 +226,7 @@
|
||||||
(eq? 'foo-closure (procedure-name bar-closure)))
|
(eq? 'foo-closure (procedure-name bar-closure)))
|
||||||
|
|
||||||
(pass-if "procedure-with-setter"
|
(pass-if "procedure-with-setter"
|
||||||
(eq? 'foo-pws (pk (procedure-name bar-pws)))))
|
(eq? 'foo-pws (procedure-name bar-pws))))
|
||||||
|
|
||||||
(if old-procnames-flag
|
(if old-procnames-flag
|
||||||
(debug-enable 'procnames)
|
(debug-enable 'procnames)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue