Page 1 of 1

Lisp eval and read-from-string

Posted: Wed Aug 29, 2012 6:30 pm
by sms1989
Hey everyone,

I've been slowly learning Lisp, but really don't know much yet, so I wasn't sure what to search for here. I apologize if this question has already been posted.

I came across a combined Lisp statement: (eval (read-from-string (read-line))) ⇒ ???

I attempted to create a Lisp app to test it, but I am running into problems. My question is, after creating an application with the above statement (or a very similar statement), what would I enter in order to return an answer (once the app is running)? From what I have read, there are 3 ways to enter a line for the compiler to read, but only one way is accepted and the other 2 methods return exception errors. Could you tell me what I would enter to return a valid answer and what I would enter to return the exception errors?

Sorry if that is confusing. I am pretty confused myself. Thanks everyone!

Re: Lisp eval and read-from-string

Posted: Thu Aug 30, 2012 4:31 am
by sylwester
:roll: read-line reads one line so you must type in a whole expression in one line.
read-from-string reads a string until ithas a whole expression andreturns a expression as data

These two ar like read, only read reads from input until it has a whole expression.

You may input self evaluating stuff like numbers or something like (if T (print 'boo) (print 'wonnthappen))