sbcl newbie question

Whatever is on your mind, whether Lisp related or not.
Post Reply
joybee
Posts: 21
Joined: Wed Jan 07, 2009 1:49 pm

sbcl newbie question

Post by joybee » Wed Jan 07, 2009 2:02 pm

I just start to learn Lisp. And my question is

When I enter (princ "Hello"), why there are two lines of Hello printed out, one without quote, one with double quote. Same happened to print or write-line. But when I type (format t "Hello"), only one line Hello came out with Nil.

Can anyone explain why it works this way? Thanks!

dmitry_vk
Posts: 96
Joined: Sat Jun 28, 2008 8:01 am
Location: Russia, Kazan
Contact:

Re: sbcl newbie question

Post by dmitry_vk » Wed Jan 07, 2009 3:14 pm

joybee wrote:I just start to learn Lisp. And my question is

When I enter (princ "Hello"), why there are two lines of Hello printed out, one without quote, one with double quote. Same happened to print or write-line. But when I type (format t "Hello"), only one line Hello came out with Nil.

Can anyone explain why it works this way? Thanks!
You enter the expression into the REPL (Read-Eval-Print Loop), which evaluates the expression and prints the result. print and princ return their argument. So, one line is printed from print/princ themselves, and the other is from the REPL. (format t ...) returns NIL, so NIL is printed.

joybee
Posts: 21
Joined: Wed Jan 07, 2009 1:49 pm

Re: sbcl newbie question

Post by joybee » Thu Jan 08, 2009 8:05 am

Thanks for your help, Dmitry!

I am so glad that I found this forum. Thanks for the site, Dave!

Post Reply