Function: safe-length
safe-length is a function defined in fns.c.
Signature
(safe-length LIST)
Documentation
Return the length of a list, but avoid error or infinite loop.
This function never gets an error. If LIST is not really a list, it returns 0. If LIST is circular, it returns an integer that is at least the number of distinct elements.
Other relevant functions are documented in the list group.
Probably introduced at or before Emacs version 19.30.
Shortdoc
;; list
(safe-length '(a b c))
=> 3
Source Code
// Defined in /usr/src/emacs/src/fns.c
{
intptr_t len = 0;
FOR_EACH_TAIL_SAFE (list)
len++;
return make_fixnum (len);
}