The very beginning of a talking program - error

Discussion of Common Lisp
Post Reply
Grafoam
Posts: 1
Joined: Mon Mar 23, 2015 4:02 am

The very beginning of a talking program - error

Post by Grafoam » Mon Mar 23, 2015 4:11 am

Hello everybody,

I'm currently learning LISP since i've ever wanted to program a talking bot. I've looked around on the web and found many example and i've chosen LISP for both the challenge of learning a new language, the logical approach and recommendation about this language.

I've learned the basics, and now i'm starting to (and i know it is bad !) random try some program to start my project.

First, and so easy for everybody that i couldn't find any help on this, i want to catch input (as a string) from the user.

I've created a mini .lisp file with the following code :

Code: Select all

defun( read-input ()
		(format t "Enter text : ")
		(let (s (read-line)))
		(format t "You entered ~s~%" s)
	)
When I load the program, i get a "DEFUN is unbound." error.

For now i'm stuck with this... If you could breing some enlightment to me, I would greatly appreciate,

Regards,

Charles

PS: My english is not my mother language so please feel free to correct me (so i can learn from my mistake) or just forgive my mistakes.

Goheeca
Posts: 271
Joined: Thu May 10, 2012 12:54 pm
Contact:

Re: The very beginning of a talking program - error

Post by Goheeca » Fri Mar 27, 2015 12:09 am

The defun isn't a special construction, the parenthesis has to be in front of it.

Code: Select all

(defun read-input ()
  (format t "Enter text: ")
  (let ((s (read-line)))
    (format t "You entered: ~a~%" s)))
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.

Post Reply