* [PATCH] Add scm_is_list helper function
@ 2017-06-02 12:47 Matthew Keeter
0 siblings, 0 replies; only message in thread
From: Matthew Keeter @ 2017-06-02 12:47 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 233 bytes --]
For symmetry with scm_is_number, scm_is_pair, etc, this small patch adds
scm_is_list to the C API. I pattern-matched to find all the places it should go
(both code and documentation); let me know if I missed anything.
-Matt
[-- Attachment #2: 0001-Add-scm_is_list-helper-function.patch --]
[-- Type: application/octet-stream, Size: 1562 bytes --]
From 2fed26cfa1f3bdd67b74ee755b63fcec341a6bf1 Mon Sep 17 00:00:00 2001
From: Matt Keeter <matt.j.keeter@gmail.com>
Date: Thu, 1 Jun 2017 09:32:33 -0400
Subject: [PATCH] Add scm_is_list helper function
---
doc/ref/api-data.texi | 4 ++++
libguile/list.c | 5 +++++
libguile/list.h | 1 +
3 files changed, 10 insertions(+)
diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 7b10d34..5c36ca2 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -5846,6 +5846,10 @@ Return @code{#t} if @var{x} is the empty list, else @code{#f}.
Return 1 when @var{x} is the empty list; otherwise return 0.
@end deftypefn
+@deftypefn {C Function} int scm_is_list (SCM obj)
+This is equivalent to @code{scm_is_true (scm_list_p (obj))}.
+@end deftypefn
+
@node List Constructors
@subsubsection List Constructors
diff --git a/libguile/list.c b/libguile/list.c
index 9396315..07ffc5c 100644
--- a/libguile/list.c
+++ b/libguile/list.c
@@ -1001,6 +1001,11 @@ SCM_DEFINE (scm_filter_x, "filter!", 2, 0, 0,
}
#undef FUNC_NAME
+int
+scm_is_list (SCM t)
+{
+ return scm_is_true (scm_list_p (t));
+}
\f
void
scm_init_list ()
diff --git a/libguile/list.h b/libguile/list.h
index 238926e..32821d8 100644
--- a/libguile/list.h
+++ b/libguile/list.h
@@ -69,6 +69,7 @@ SCM_API SCM scm_filter (SCM pred, SCM list);
SCM_API SCM scm_filter_x (SCM pred, SCM list);
SCM_API SCM scm_copy_tree (SCM obj);
+SCM_API int scm_is_list (SCM x);
\f
/* Guile internal functions */
--
2.9.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-06-02 12:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-02 12:47 [PATCH] Add scm_is_list helper function Matthew Keeter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).