From 46251d33353746e248d2cee3bb2cc6e9f489b67a Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Fri, 26 Nov 2004 04:42:06 +0000 Subject: [PATCH] Change GET-KEYWORD-VALUE to return #!DEFAULT when not found. Add procedures to map between keyword lists and alists. --- v7/src/runtime/list.scm | 21 ++++++++++++++++++--- v7/src/runtime/runtime.pkg | 4 +++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/v7/src/runtime/list.scm b/v7/src/runtime/list.scm index 14da1d595..aa63c7340 100644 --- a/v7/src/runtime/list.scm +++ b/v7/src/runtime/list.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: list.scm,v 14.44 2004/11/22 06:31:03 cph Exp $ +$Id: list.scm,v 14.45 2004/11/26 04:41:59 cph Exp $ Copyright 1986,1987,1988,1989,1990,1991 Massachusetts Institute of Technology Copyright 1992,1993,1994,1995,1996,2000 Massachusetts Institute of Technology @@ -1076,7 +1076,7 @@ USA. (define (error:not-restricted-keyword-list object caller) (error:wrong-type-argument object "restricted keyword list" caller)) -(define (get-keyword-value klist key default) +(define (get-keyword-value klist key) (let ((lose (lambda () (error:not-keyword-list klist 'GET-KEYWORD-VALUE)))) (let loop ((klist klist)) (if (pair? klist) @@ -1089,7 +1089,22 @@ USA. (begin (if (not (null? klist)) (lose)) - default))))) + #!default))))) + +(define (keyword-list->alist klist) + (let loop ((klist klist)) + (if (pair? klist) + (cons (cons (car klist) (cadr klist)) + (loop (cddr klist))) + '()))) + +(define (alist->keyword-list alist) + (let loop ((alist alist)) + (if (pair? alist) + (cons (caar alist) + (cons (cdar alist) + (loop (cdr alist)))) + '()))) ;;;; Lastness and Segments diff --git a/v7/src/runtime/runtime.pkg b/v7/src/runtime/runtime.pkg index 1c3df74b1..5b6ffaec5 100644 --- a/v7/src/runtime/runtime.pkg +++ b/v7/src/runtime/runtime.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: runtime.pkg,v 14.518 2004/11/25 04:00:21 cph Exp $ +$Id: runtime.pkg,v 14.519 2004/11/26 04:42:06 cph Exp $ Copyright 1988,1989,1990,1991,1992,1993 Massachusetts Institute of Technology Copyright 1994,1995,1996,1997,1998,1999 Massachusetts Institute of Technology @@ -2047,6 +2047,7 @@ USA. (list-transform-negative delete-matching-items) (list-transform-positive keep-matching-items) add-member-procedure + alist->keyword-list alist-copy alist? append @@ -2137,6 +2138,7 @@ USA. guarantee-restricted-keyword-list guarantee-weak-list keep-matching-items + keyword-list->alist keyword-list? last-pair length -- 2.25.1