guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 01/01: Implement SRFI 28: Basic Format Strings.


From: Mark H. Weaver
Subject: [Guile-commits] 01/01: Implement SRFI 28: Basic Format Strings.
Date: Tue, 02 Dec 2014 17:34:34 +0000

mhw pushed a commit to branch stable-2.0
in repository guile.

commit cffa9bd6a36d0ab38d700851beb0fcc44a191c17
Author: Chris Jester-Young <address@hidden>
Date:   Sun Nov 30 05:20:54 2014 -0500

    Implement SRFI 28: Basic Format Strings.
    
    * module/srfi/srfi-28.scm: New module.
    * module/Makefile.am (SRFI_SOURCES): Add srfi/srfi-28.scm.
    * doc/ref/srfi-modules.texi (SRFI-28): New node.
---
 doc/ref/srfi-modules.texi |   37 +++++++++++++++++++++++++++++++++++++
 module/Makefile.am        |    1 +
 module/srfi/srfi-28.scm   |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi
index 2cf9fd1..d8ed8e1 100644
--- a/doc/ref/srfi-modules.texi
+++ b/doc/ref/srfi-modules.texi
@@ -38,6 +38,7 @@ get the relevant SRFI documents from the SRFI home page
 * SRFI-23::                     Error reporting
 * SRFI-26::                     Specializing parameters
 * SRFI-27::                     Sources of Random Bits
+* SRFI-28::                     Basic format strings.
 * SRFI-30::                     Nested multi-line block comments
 * SRFI-31::                     A special form `rec' for recursive evaluation
 * SRFI-34::                     Exception handling.
@@ -3276,6 +3277,42 @@ reasonably small value (related to the width of the 
mantissa of an
 efficient number format).
 @end defun
 
address@hidden SRFI-28
address@hidden SRFI-28 - Basic Format Strings
address@hidden SRFI-28
+
+SRFI-28 provides a basic @code{format} procedure that provides only
+the @code{~a}, @code{~s}, @code{~%}, and @code{~~} format specifiers.
+You can import this procedure by using:
+
address@hidden
+(use-modules (srfi srfi-28))
address@hidden lisp
+
address@hidden {Scheme Procedure} format message arg @dots{}
+Returns a formatted message, using @var{message} as the format string,
+which can contain the following format specifiers:
+
address@hidden @code
address@hidden ~a
+Insert the textual representation of the next @var{arg}, as if printed
+by @code{display}.
+
address@hidden ~s
+Insert the textual representation of the next @var{arg}, as if printed
+by @code{write}.
+
address@hidden ~%
+Insert a newline.
+
address@hidden ~~
+Insert a tilde.
address@hidden table
+
+This procedure is the same as calling @code{simple-format} (@pxref{Writing})
+with @code{#f} as the destination.
address@hidden deffn
+
 @node SRFI-30
 @subsection SRFI-30 - Nested Multi-line Comments
 @cindex SRFI-30
diff --git a/module/Makefile.am b/module/Makefile.am
index a9aaa76..7e96de7 100644
--- a/module/Makefile.am
+++ b/module/Makefile.am
@@ -278,6 +278,7 @@ SRFI_SOURCES = \
   srfi/srfi-19.scm \
   srfi/srfi-26.scm \
   srfi/srfi-27.scm \
+  srfi/srfi-28.scm \
   srfi/srfi-31.scm \
   srfi/srfi-34.scm \
   srfi/srfi-35.scm \
diff --git a/module/srfi/srfi-28.scm b/module/srfi/srfi-28.scm
new file mode 100644
index 0000000..7fc73eb
--- /dev/null
+++ b/module/srfi/srfi-28.scm
@@ -0,0 +1,34 @@
+;;; srfi-28.scm --- Basic Format Strings
+
+;; Copyright (C) 2014 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 3 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
+
+;;; Commentary:
+
+;; This module provides a wrapper for simple-format that always outputs
+;; to a string.
+;;
+;; This module is documented in the Guile Reference Manual.
+
+;;; Code:
+
+(define-module (srfi srfi-28)
+  #:replace (format))
+
+(define (format message . args)
+  (apply simple-format #f message args))
+
+(cond-expand-provide (current-module) '(srfi-28))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]