1

Experiment on interative ielm

ELISP> (print 'list)

list

list
ELISP> (print "list")

"list"

"list"

Any differences with the two results? by the way, one extra times printed.

6

'list and "list" are different datatypes:

ELISP> (type-of 'list)
symbol
ELISP> (type-of "list")
string

Note that they even show up differently in your example -- it's the difference between list and "list".

But why do they show up twice? Well, because the REPL displays anything printed out, but also prints out the return value of the s-expression. For example:

ELISP> 3
3 (#o3, #x3, ?\C-c)
ELISP> "I'm being returned!"
"I'm being returned!"

So if we use progn, which runs all of its arguments and returns the last one, we can see the difference between a printed value and a returned one:

ELISP> (progn (print "I'm being printed") 'not-printed)

"I'm being printed"

not-printed
ELISP> (progn 'not-printed (print "I'm being printed"))

"I'm being printed"

"I'm being printed"

See how in the first example, the printed value shows up, followed by the not printed one? 'not-printed only ever shows up because it's returned; in the second example, we don't see 'not-printed ever show up! We see "I'm being printed" twice -- first printed, then returned.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.