Improve the documentation for 'nil?'.
authorMark H Weaver <mhw@netris.org>
Sun, 14 Oct 2018 05:32:58 +0000 (01:32 -0400)
committerMark H Weaver <mhw@netris.org>
Sun, 14 Oct 2018 05:37:37 +0000 (01:37 -0400)
* 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
libguile/boolean.c

index 839e6eae27bed562aec893a2777f63a1db62a86f..763e7985966c9db832ffa11afab81d4849613723 100644 (file)
@@ -1,7 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
-@c Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2010
-@c   Free Software Foundation, Inc.
+@c Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2010, 2016,
+@c   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
+@code{nil}, 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?}:
+
+@deffn {Scheme Procedure} nil? obj
+Return @code{#t} if @var{obj} would be interpreted as @code{nil} by
+Emacs Lisp code, else return @code{#f}.
+
+@lisp
+(nil? #nil) @result{} #t
+(nil? #f)   @result{} #t
+(nil? '())  @result{} #t
+(nil? 3)    @result{} #f
+@end lisp
+@end 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:
index f8c773839a133edb6cdb94cd670bab034f90129f..635c149054783ed34af9091d4d9b37aa3ac6b39f 100644 (file)
@@ -1,4 +1,5 @@
-/*     Copyright (C) 1995, 1996, 2000, 2001, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 2000, 2001, 2006, 2008-2011, 2018
+ *   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
@@ -64,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));