This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

sbcl newbie question

3 posts · 3163 views

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

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

Thanks for your help, Dmitry!

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