From 238f5999bc146b926b5a539e459f780a9fd44d8d Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sat, 18 Jul 2015 15:22:33 +0900 Subject: [PATCH] dictionary-ref now returns a pair or #f --- contrib/40.srfi/srfi/17.scm | 6 +++--- docs/libs.rst | 2 +- extlib/benz/dict.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/40.srfi/srfi/17.scm b/contrib/40.srfi/srfi/17.scm index 0a7bdbad..66c0061c 100644 --- a/contrib/40.srfi/srfi/17.scm +++ b/contrib/40.srfi/srfi/17.scm @@ -17,9 +17,9 @@ (letrec ((setter (lambda (proc) (let ((setter (dictionary-ref (attribute proc) '@@setter))) - (if (undefined? setter) - (error "no setter found") - setter)))) + (if setter + (cdr setter) + (error "no setter found"))))) (set-setter! (lambda (proc setter) (dictionary-set! (attribute proc) '@@setter setter)))) diff --git a/docs/libs.rst b/docs/libs.rst index 232dcdaa..a8b441a3 100644 --- a/docs/libs.rst +++ b/docs/libs.rst @@ -117,7 +117,7 @@ Symbol-to-object hash table. - **(dictionary-ref dict key)** - Look up dictionary dict for a value associated with key. If dict has a slot for key `key`, the value stored in the slot is returned. Otherwise `#undefined` is returned. + Look up dictionary dict for a value associated with key. If dict has a slot for key `key`, a pair containing the key object and the associated value is returned. Otherwise `#f` is returned. - **(dictionary-set! dict key obj)** diff --git a/extlib/benz/dict.c b/extlib/benz/dict.c index f8514524..b1c3783b 100644 --- a/extlib/benz/dict.c +++ b/extlib/benz/dict.c @@ -116,9 +116,9 @@ pic_dict_dictionary_ref(pic_state *pic) pic_get_args(pic, "dm", &dict, &key); if (! pic_dict_has(pic, dict, key)) { - return pic_undef_value(); + return pic_false_value(); } - return pic_dict_ref(pic, dict, key); + return pic_cons(pic, pic_obj_value(key), pic_dict_ref(pic, dict, key)); } static pic_value