e19293001
e19293001

Reputation: 2901

{ returning a string from a function } EVAL: variable has no value

I'm unable to print the return value of return-str.

; return-str.lisp
(defun ask-for-input(str)
  (princ str)
  (let ((cmd (read-line)))
    cmd))
(defun return-str()
  (let ((data-str (ask-for-input "enter a string")))
    (data-str)))
(princ return-str)

Executing the code above with clisp, I got:

$ clisp return-str.lisp
*** - EVAL: variable RETURN-STR has no value

Please help me on how to properly return a string from return-str.

Thank you.

Upvotes: 0

Views: 1880

Answers (1)

sigjuice
sigjuice

Reputation: 29759

Your parentheses are incorrect in a couple of places.

  • (data-str) should be replaced with data-str because data-str is not a function.
  • (princ return-str) should be replaced with (princ (return-str)) because return-str is a function.

Upvotes: 3

Related Questions