Page 1 of 1

sbcl newbie question

Posted: Wed Jan 07, 2009 2:02 pm
by joybee
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!

Re: sbcl newbie question

Posted: Wed Jan 07, 2009 3:14 pm
by dmitry_vk
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.

Re: sbcl newbie question

Posted: Thu Jan 08, 2009 8:05 am
by joybee
Thanks for your help, Dmitry!

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