Subject: Re: how to validate input?
From: Erik Naggum <>
Date: 2000/04/19
Newsgroups: comp.lang.lisp
Message-ID: <>

* Friedrich Dominicus <>
| I have written the same with a loop but it looks IMO more ugly.

  it's quite strange, but people who have been trained to write iteration
  using tail recursion tend to write the most amazingly ugly loops, and it
  isn't a question of lack of training in writing loops, it's conceptual.
  (yet another case of Scheme hurting people.)

| (defun get-input ()
| (let ((line))
|   (do ((exit nil))
|       (exit line)
|     (format t "Please give me a number (e for Exit): ")
|     (setf line (read))
|     (if (numberp line)
|         (progn 
|           (setf exit t)
|           line)
|       (when (y-or-n-p "Not a number, really exit?")
|         (setf exit t)
|         (setf line nil))))))

(format t "please enter a number: ")
(do ((input (read nil nil nil) (read nil nil nil)))
    ((or (null input) (numberp input)) input)
  (format t "not a number, try again: "))

  I'd use a different input function that read, but that's your call.