Handling deep list recursion

Heime <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <F52xMcKQjd0RbisNr4vyqzZISN1ztRuHMROai0iJd5-zXtl8cn1vKDnrxTOlDjL0rU8oPXAPkFgru19PBBwADVMm2i2ytlFudZmSLZtH1X0=@protonmail.com>
I want to handle the recursion situation when list is too big.  
What would be the best plan when it is too long?  Catch the error 
if it happens and continue with nonlocal exit than continues with
cl-every?  Of compute the length beforehand?

(defun lana-alistp (object &optional recursive)
  "Non-nil if and only if OBJECT is a valid alist.
Validate every element is proper (KEY . VALUE) cons cell."

  (declare (pure t) (side-effect-free error-free))
  (when (proper-list-p object)
    (if recursive
	(cond ((atom object)  (eq object nil))
              (t  (and (consp (car object))
                       (lana-alistp (cdr object)))))
      (cl-every #'consp object))))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.