[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 07/55: Improve the documentation for 'nil?'.
From: |
Andy Wingo |
Subject: |
[Guile-commits] 07/55: Improve the documentation for 'nil?'. |
Date: |
Thu, 23 May 2019 11:52:37 -0400 (EDT) |
wingo pushed a commit to branch master
in repository guile.
commit 0c0a658c564c4c585d740c8ccf16b889f996ac3f
Author: Mark H Weaver <address@hidden>
Date: Sun Oct 14 01:32:58 2018 -0400
Improve the documentation for 'nil?'.
* libguile/boolean.c (scm_nil_p): Improve docstring.
* doc/ref/api-languages.texi (Nil): Add documentation for 'nil?', along
with a description of how Elisp interprets Scheme booleans and
end-of-list.
---
doc/ref/api-languages.texi | 22 ++++++++++++++++++++--
libguile/boolean.c | 12 ++++++++++--
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/doc/ref/api-languages.texi b/doc/ref/api-languages.texi
index 839e6ea..763e798 100644
--- a/doc/ref/api-languages.texi
+++ b/doc/ref/api-languages.texi
@@ -1,7 +1,7 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2010
address@hidden Free Software Foundation, Inc.
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2010,
2016,
address@hidden 2017, 2018 Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node Other Languages
@@ -108,6 +108,24 @@ code to maintain their current semantics. @code{nil},
which in Elisp
would just be written and read as @code{nil}, in Scheme has the external
representation @code{#nil}.
+In Elisp code, @code{#nil}, @code{#f}, and @code{'()} behave like
address@hidden, in the sense that they are all interpreted as @code{nil} by
+Elisp @code{if}, @code{cond}, @code{when}, @code{not}, @code{null}, etc.
+To test whether Elisp would interpret an object as @code{nil} from
+within Scheme code, use @code{nil?}:
+
address@hidden {Scheme Procedure} nil? obj
+Return @code{#t} if @var{obj} would be interpreted as @code{nil} by
+Emacs Lisp code, else return @code{#f}.
+
address@hidden
+(nil? #nil) @result{} #t
+(nil? #f) @result{} #t
+(nil? '()) @result{} #t
+(nil? 3) @result{} #f
address@hidden lisp
address@hidden deffn
+
This decision to have @code{nil} as a low-level distinct value
facilitates interoperability between the two languages. Guile has chosen
to have Scheme deal with @code{nil} as follows:
diff --git a/libguile/boolean.c b/libguile/boolean.c
index 659d8d4..e837033 100644
--- a/libguile/boolean.c
+++ b/libguile/boolean.c
@@ -1,4 +1,4 @@
-/* Copyright 1995-1996,2000-2001,2006,2008-2011,2018
+/* Copyright 1995-1996,2000-2001,2006,2008-2011,2018,2019
Free Software Foundation, Inc.
This file is part of Guile.
@@ -65,7 +65,15 @@ SCM_DEFINE (scm_not, "not", 1, 0, 0,
SCM_DEFINE (scm_nil_p, "nil?", 1, 0, 0,
(SCM x),
- "Return @code{#t} iff @var{x} is nil, else return @code{#f}.")
+ "Return @code{#t} if @var{x} would be interpreted as @code{nil}\n"
+ "by Emacs Lisp code, else return @code{#f}.\n"
+ "\n"
+ "@example\n"
+ "(nil? #nil) @result{} #t\n"
+ "(nil? #f) @result{} #t\n"
+ "(nil? '()) @result{} #t\n"
+ "(nil? 3) @result{} #f\n"
+ "@end example")
#define FUNC_NAME s_scm_nil_p
{
return scm_from_bool (scm_is_lisp_false (x));
- [Guile-commits] 15/55: Use 'scm_from_utf8_{string, symbol, keyword}' for C string literals., (continued)
- [Guile-commits] 15/55: Use 'scm_from_utf8_{string, symbol, keyword}' for C string literals., Andy Wingo, 2019/05/23
- [Guile-commits] 23/55: SRFI-19: Check for incompatible types in time comparisons., Andy Wingo, 2019/05/23
- [Guile-commits] 34/55: Don't mutate read-only string in ports test, Andy Wingo, 2019/05/23
- [Guile-commits] 36/55: Fix strftime compile with null threads, Andy Wingo, 2019/05/23
- [Guile-commits] 25/55: SRFI-19: Minor refactor of leap second table lookups., Andy Wingo, 2019/05/23
- [Guile-commits] 45/55: Update user-visible copyright years., Andy Wingo, 2019/05/23
- [Guile-commits] 46/55: Fix gc.test "after-gc-hook gets called" failures., Andy Wingo, 2019/05/23
- [Guile-commits] 55/55: Update iconv.m4 from gnulib., Andy Wingo, 2019/05/23
- [Guile-commits] 50/55: Fix indentation in scm_sum., Andy Wingo, 2019/05/23
- [Guile-commits] 48/55: Add 'scm_c_make_char' and use it where appropriate., Andy Wingo, 2019/05/23
- [Guile-commits] 07/55: Improve the documentation for 'nil?'.,
Andy Wingo <=
- [Guile-commits] 17/55: Fix typo in strings.h., Andy Wingo, 2019/05/23
- [Guile-commits] 18/55: scm_seed_to_random_state: Support wide string arguments., Andy Wingo, 2019/05/23
- [Guile-commits] 35/55: Remove redefinition of when & unless in snarf-check-and-output-texi, Andy Wingo, 2019/05/23
- [Guile-commits] 41/55: Make locale monetary conversion tests be less strict on terminal whitespace, Andy Wingo, 2019/05/23
- [Guile-commits] 39/55: Add a fallback value for the locale-monetary-decimal-point, Andy Wingo, 2019/05/23
- [Guile-commits] 40/55: Handle newlib C library's langinfo constant names, Andy Wingo, 2019/05/23
- [Guile-commits] 19/55: SRFI-19: Fix TAI->UTC conversions, leap second handling, etc., Andy Wingo, 2019/05/23