mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Add `(srfi srfi-88)'.
This commit is contained in:
parent
e9680652d6
commit
efbc70de56
10 changed files with 188 additions and 7 deletions
4
NEWS
4
NEWS
|
@ -15,6 +15,10 @@ The new repository can be accessed using
|
|||
"git-clone git://git.sv.gnu.org/guile.git", or can be browsed on-line at
|
||||
http://git.sv.gnu.org/gitweb/?p=guile.git . See `README' for details.
|
||||
|
||||
* New modules (see the manual for details)
|
||||
|
||||
** `(srfi srfi-88)'
|
||||
|
||||
* New features (see the manual for details)
|
||||
|
||||
** New `postfix' read option, for SRFI-88 keyword syntax
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2008-04-26 Ludovic Courtès <ludo@gnu.org>
|
||||
|
||||
* srfi-modules.texi (SRFI-88): New section.
|
||||
* api-data.texi (Keyword Read Syntax): Add reference to
|
||||
`SRFI-88'.
|
||||
|
||||
2008-04-17 Neil Jerram <neil@ossau.uklinux.net>
|
||||
|
||||
* posix.texi (File System): New doc for file-exists?.
|
||||
|
|
|
@ -5042,9 +5042,8 @@ of the form @code{:NAME} are read as symbols, as required by R5RS.
|
|||
@cindex SRFI-88 keyword syntax
|
||||
|
||||
If the @code{keyword} read option is set to @code{'postfix}, Guile
|
||||
recognizes the @uref{http://srfi.schemers.org/srfi-88/srfi-88.html,
|
||||
SRFI-88 read syntax} @code{NAME:}. Otherwise, tokens of this form are
|
||||
read as symbols.
|
||||
recognizes the SRFI-88 read syntax @code{NAME:} (@pxref{SRFI-88}).
|
||||
Otherwise, tokens of this form are read as symbols.
|
||||
|
||||
To enable and disable the alternative non-R5RS keyword syntax, you use
|
||||
the @code{read-set!} procedure documented in @ref{User level options
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@c -*-texinfo-*-
|
||||
@c This is part of the GNU Guile Reference Manual.
|
||||
@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 2007
|
||||
@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008
|
||||
@c Free Software Foundation, Inc.
|
||||
@c See the file guile.texi for copying conditions.
|
||||
|
||||
|
@ -45,6 +45,7 @@ get the relevant SRFI documents from the SRFI home page
|
|||
* SRFI-60:: Integers as bits.
|
||||
* SRFI-61:: A more general `cond' clause
|
||||
* SRFI-69:: Basic hash tables.
|
||||
* SRFI-88:: Keyword objects.
|
||||
@end menu
|
||||
|
||||
|
||||
|
@ -3215,6 +3216,56 @@ Answer a hash value appropriate for equality predicate @code{equal?},
|
|||
@code{hash} is a backwards-compatible replacement for Guile's built-in
|
||||
@code{hash}.
|
||||
|
||||
@node SRFI-88
|
||||
@subsection SRFI-88 Keyword Objects
|
||||
@cindex SRFI-88
|
||||
@cindex keyword objects
|
||||
|
||||
@uref{http://srfi.schemers.org/srfi/srfi-88.html, SRFI-88} provides
|
||||
@dfn{keyword objects}, which are equivalent to Guile's keywords
|
||||
(@pxref{Keywords}). SRFI-88 keywords can be entered using the
|
||||
@dfn{postfix keyword syntax}, which consists of an identifier followed
|
||||
by @code{:} (@pxref{Reader options, @code{postfix} keyword syntax}).
|
||||
SRFI-88 can be made available with:
|
||||
|
||||
@example
|
||||
(use-modules (srfi srfi-88))
|
||||
@end example
|
||||
|
||||
Doing so installs the right reader option for keyword syntax, using
|
||||
@code{(read-set! keywords 'postfix)}. It also provides the procedures
|
||||
described below.
|
||||
|
||||
@deffn {Scheme Procedure} keyword? obj
|
||||
Return @code{#t} if @var{obj} is a keyword. This is the same procedure
|
||||
as the same-named built-in procedure (@pxref{Keyword Procedures,
|
||||
@code{keyword?}}).
|
||||
|
||||
@example
|
||||
(keyword? foo:) @result{} #t
|
||||
(keyword? 'foo:) @result{} #t
|
||||
(keyword? "foo") @result{} #f
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn {Scheme Procedure} keyword->string kw
|
||||
Return the name of @var{kw} as a string, i.e., without the trailing
|
||||
colon. The returned string may not be modified, e.g., with
|
||||
@code{string-set!}.
|
||||
|
||||
@example
|
||||
(keyword->string foo:) @result{} "foo"
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn {Scheme Procedure} string->keyword str
|
||||
Return the keyword object whose name is @var{str}.
|
||||
|
||||
@example
|
||||
(keyword->string (string->keyword "a b c")) @result{} "a b c"
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
|
||||
@c srfi-modules.texi ends here
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2008-04-26 Ludovic Courtès <ludo@gnu.org>
|
||||
|
||||
* Makefile.am (srfi_DATA): Add `srfi-88.scm'.
|
||||
* srfi-88.scm: New file.
|
||||
|
||||
2008-03-12 Ludovic Courtès <ludo@gnu.org>
|
||||
|
||||
* srfi-37.scm (args-fold)[short-option]: Set ARGS to `(cdr
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## Process this file with Automake to create Makefile.in
|
||||
##
|
||||
## Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
##
|
||||
## This file is part of GUILE.
|
||||
##
|
||||
|
@ -78,7 +78,8 @@ srfi_DATA = srfi-1.scm \
|
|||
srfi-37.scm \
|
||||
srfi-39.scm \
|
||||
srfi-60.scm \
|
||||
srfi-69.scm
|
||||
srfi-69.scm \
|
||||
srfi-88.scm
|
||||
|
||||
EXTRA_DIST = $(srfi_DATA)
|
||||
TAGS_FILES = $(srfi_DATA)
|
||||
|
|
50
srfi/srfi-88.scm
Normal file
50
srfi/srfi-88.scm
Normal file
|
@ -0,0 +1,50 @@
|
|||
;;; srfi-88.scm --- Keyword Objects
|
||||
|
||||
;; Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
;;
|
||||
;; This library is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU Lesser General Public
|
||||
;; License as published by the Free Software Foundation; either
|
||||
;; version 2.1 of the License, or (at your option) any later version.
|
||||
;;
|
||||
;; This library is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;; Lesser General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU Lesser General Public
|
||||
;; License along with this library; if not, write to the Free Software
|
||||
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
;;; Author: Ludovic Courtès <ludo@gnu.org>
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This is a convenience module providing SRFI-88 "keyword object". All it
|
||||
;; does is setup the right reader option and export keyword-related
|
||||
;; convenience procedures.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define-module (srfi srfi-88)
|
||||
#:re-export (keyword?)
|
||||
#:export (keyword->string string->keyword))
|
||||
|
||||
(cond-expand-provide (current-module) '(srfi-88))
|
||||
|
||||
|
||||
(read-set! keywords 'postfix)
|
||||
|
||||
(define (keyword->string k)
|
||||
"Return the name of @var{k} as a string."
|
||||
(symbol->string (keyword->symbol k)))
|
||||
|
||||
(define (string->keyword s)
|
||||
"Return the keyword object whose name is @var{s}."
|
||||
(symbol->keyword (string->symbol s)))
|
||||
|
||||
;;; Local Variables:
|
||||
;;; coding: latin-1
|
||||
;;; End:
|
||||
|
||||
;;; srfi-88.scm ends here
|
|
@ -1,3 +1,8 @@
|
|||
2008-04-26 Ludovic Courtès <ludo@gnu.org>
|
||||
|
||||
* Makefile.am (SCM_TESTS): Add `tests/srfi-88.test'.
|
||||
* tests/srfi-88.test: New file.
|
||||
|
||||
2008-04-15 Ludovic Courtès <ludo@gnu.org>
|
||||
|
||||
* tests/reader.test (read-options)[prefix non-keywords, postfix
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## Process this file with automake to produce Makefile.in.
|
||||
##
|
||||
## Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 Software Foundation, Inc.
|
||||
## Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Software Foundation, Inc.
|
||||
##
|
||||
## This file is part of GUILE.
|
||||
##
|
||||
|
@ -80,6 +80,7 @@ SCM_TESTS = tests/alist.test \
|
|||
tests/srfi-39.test \
|
||||
tests/srfi-60.test \
|
||||
tests/srfi-69.test \
|
||||
tests/srfi-88.test \
|
||||
tests/srfi-4.test \
|
||||
tests/srfi-9.test \
|
||||
tests/strings.test \
|
||||
|
|
59
test-suite/tests/srfi-88.test
Normal file
59
test-suite/tests/srfi-88.test
Normal file
|
@ -0,0 +1,59 @@
|
|||
;;;; srfi-88.test --- Test suite for SRFI-88 -*- Scheme -*-
|
||||
;;;; Ludovic Courtès <ludo@gnu.org>
|
||||
;;;;
|
||||
;;;; Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This program is free software; you can redistribute it and/or modify
|
||||
;;;; it under the terms of the GNU General Public License as published by
|
||||
;;;; the Free Software Foundation; either version 2, or (at your option)
|
||||
;;;; any later version.
|
||||
;;;;
|
||||
;;;; This program is distributed in the hope that it will be useful,
|
||||
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;;; GNU General Public License for more details.
|
||||
;;;;
|
||||
;;;; You should have received a copy of the GNU General Public License
|
||||
;;;; along with this software; see the file COPYING. If not, write to
|
||||
;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;;;; Boston, MA 02110-1301 USA
|
||||
|
||||
(define-module (test-srfi-88)
|
||||
:use-module (test-suite lib)
|
||||
:use-module (srfi srfi-88))
|
||||
|
||||
|
||||
;; Most of the test cases are taken from SRFI-88.
|
||||
|
||||
(with-test-prefix "srfi-88"
|
||||
|
||||
(pass-if "cond-expand"
|
||||
(cond-expand (srfi-88 #t)
|
||||
(else #f)))
|
||||
|
||||
(pass-if "keyword?"
|
||||
(and (keyword? 'foo:)
|
||||
(keyword? foo:)
|
||||
(not (keyword? 'foo))
|
||||
(not (keyword? ':))
|
||||
(keyword? (car '(a: b:)))
|
||||
(not (keyword? "bar"))))
|
||||
|
||||
(pass-if "keyword->string"
|
||||
(and (string=? (keyword->string foo:) "foo")
|
||||
(string=? "a b c"
|
||||
(keyword->string (string->keyword "a b c")))))
|
||||
|
||||
(pass-if "string->keyword"
|
||||
(eq? (string->keyword "foo") foo:))
|
||||
|
||||
(pass-if "empty keyword"
|
||||
;; XXX: We don't currently support syntax of the form
|
||||
;; `#{extended symbol}#:'.
|
||||
(string=? ""
|
||||
(keyword->string (string->keyword "")))))
|
||||
|
||||
|
||||
;;; Local Variables:
|
||||
;;; coding: latin-1
|
||||
;;; End:
|
Loading…
Add table
Add a link
Reference in a new issue