From: Donald Fisk
Subject: Behaviour of print
Date: 
Message-ID: <3801C672.EB834D42@inthan.be>
This might seem like a newbie question, but it's something
I've been aware of and just accepted for almost two decades,
but never got around to asking about.

Why does PRINT print a newline, call PRIN1, then print a
space, instead of calling PRIN1, then printing a newline?
I'm aware of no other language which behaves the way Lisp
does, and have never been able to see any advantage in it.

Le Hibou (ma propre opinion)

-- 
"People help themselves to things if they think they will get
away with it, even things they are unlikely to have much use
for and cannot resell, such as traffic cones. In the UK we
call these people 'students'." -- Joe Boswell

From: Eugene Zaikonnikov
Subject: Re: Behaviour of print
Date: 
Message-ID: <3801DBDA.B1509202@cit.org.by>
Donald Fisk wrote:
> 
> Why does PRINT print a newline, call PRIN1, then print a
> space, instead of calling PRIN1, then printing a newline?
> I'm aware of no other language which behaves the way Lisp
> does, and have never been able to see any advantage in it.
> 

Because that is the Right Thing :) It guarantees that anything printed
with PRINT will be typed out at a new line. I also prefer to print this
way in other languages.

--
  Eugene.
From: Barry Margolin
Subject: Re: Behaviour of print
Date: 
Message-ID: <D5oM3.702$854.29247@burlma1-snr2>
In article <·················@cit.org.by>,
Eugene Zaikonnikov  <······@cit.org.by> wrote:
>Donald Fisk wrote:
>> 
>> Why does PRINT print a newline, call PRIN1, then print a
>> space, instead of calling PRIN1, then printing a newline?
>> I'm aware of no other language which behaves the way Lisp
>> does, and have never been able to see any advantage in it.
>> 
>
>Because that is the Right Thing :) It guarantees that anything printed
>with PRINT will be typed out at a new line. I also prefer to print this
>way in other languages.

PDP-10 Maclisp and Zetalisp operated in character-at-a-time mode, so it
started executing an expression as soon as you typed the closing
parenthesis, without waiting for a newline to be entered.  If PRINT didn't
print a newline first, the output would often show up on the same line as
the input, e.g.

(print 'abc)ABC

instead of

(print 'abc)
ABC

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Donald Fisk
Subject: Re: Behaviour of print
Date: 
Message-ID: <38023BF4.C797A009@inthan.be>
Barry Margolin wrote:
> PDP-10 Maclisp and Zetalisp operated in character-at-a-time mode, so it
> started executing an expression as soon as you typed the closing
> parenthesis, without waiting for a newline to be entered.  If PRINT didn't
> print a newline first, the output would often show up on the same line as
> the input, e.g.
> 
> (print 'abc)ABC
> 
> instead of
> 
> (print 'abc)
> ABC

Thank you.   Now the order of TERPRI and PRIN1 make sense.
But why the space at the end of the line?

Le Hibou (ma propre opinion)

-- 
"People help themselves to things if they think they will get
away with it, even things they are unlikely to have much use
for and cannot resell, such as traffic cones. In the UK we
call these people 'students'." -- Joe Boswell
From: Barry Margolin
Subject: Re: Behaviour of print
Date: 
Message-ID: <KcxM3.738$854.29975@burlma1-snr2>
In article <·················@inthan.be>,
Donald Fisk  <···········@inthan.be> wrote:
>But why the space at the end of the line?

When I was writing my earlier response, I got to thinking the same thing.
I couldn't think of a reason.  If you're using a series of PRINT calls,
they'll be delimited by newlines, so the space would be superfluous.  And
if you ever call PRIN1 or PRINC, it would be reasonable to expect you to
print a space first yourself.

It would make more sense if PRINT ended with a space only if the last
character printed weren't a closing delimiter, e.g. print a space after a
symbol, but not after a list.  Then we could be sure that a sequence of
PRINT followed by PRIN1 would read properly with no unnecessary whitespace.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Donald Fisk
Subject: Re: Behaviour of print
Date: 
Message-ID: <380219B5.228E53D2@inthan.be>
Eugene Zaikonnikov wrote:
> 
> Donald Fisk wrote:
> >
> > Why does PRINT print a newline, call PRIN1, then print a
> > space, instead of calling PRIN1, then printing a newline?
> > I'm aware of no other language which behaves the way Lisp
> > does, and have never been able to see any advantage in it.
> >
> 
> Because that is the Right Thing :) It guarantees that anything printed
> with PRINT will be typed out at a new line. I also prefer to print this
> way in other languages.

Your three sentences amount to a religious statement,
a blindingly obvious statement of fact, and a personal
preference.

Is the *official* reason because if you print something
with PRINT, you're guaranteed to be able to read it back
in using READ even if surrounded by other text, or is
there some other reason and if so what is it?

>   Eugene.

Le Hibou (ma propre opinion)

-- 
"People help themselves to things if they think they will get
away with it, even things they are unlikely to have much use
for and cannot resell, such as traffic cones. In the UK we
call these people 'students'." -- Joe Boswell
From: Rainer Joswig
Subject: Re: Behaviour of print
Date: 
Message-ID: <joswig-1110992058200001@194.163.195.67>
In article <·················@inthan.be>, Donald Fisk <···········@inthan.be> wrote:

> > > Why does PRINT print a newline, call PRIN1, then print a
> > > space, instead of calling PRIN1, then printing a newline?
> > > I'm aware of no other language which behaves the way Lisp
> > > does, and have never been able to see any advantage in it.

I think the following FAQ entry is atleast partly relevant:

http://www.cs.cmu.edu/Groups/AI/html/faqs/lang/lisp/part3/faq-doc-15.html
From: Christopher R. Barry
Subject: Re: Behaviour of print
Date: 
Message-ID: <87wvstvhbd.fsf@2xtreme.net>
Donald Fisk <···········@inthan.be> writes:

> Eugene Zaikonnikov wrote:
> > 
> > Donald Fisk wrote:
> > >
> > > Why does PRINT print a newline, call PRIN1, then print a
> > > space, instead of calling PRIN1, then printing a newline?
> > > I'm aware of no other language which behaves the way Lisp
> > > does, and have never been able to see any advantage in it.
> > >
> > 
> > Because that is the Right Thing :) It guarantees that anything printed
> > with PRINT will be typed out at a new line. I also prefer to print this
> > way in other languages.
> 
> Your three sentences amount to a religious statement,
> a blindingly obvious statement of fact, and a personal
> preference.
> 
> Is the *official* reason because if you print something
> with PRINT, you're guaranteed to be able to read it back
> in using READ even if surrounded by other text, or is
> there some other reason and if so what is it?

What are you _really_ complaining about? It's trivial to print an
object with a leading newline, or a fresh-line, or with no leading
characters at all. So what should PRINT do differently, in your
opinion?

FWIW, I think it would be *slightly* better if PRINT did a fresh-line
instead of a newline so that for example

  USER(173): (print 'foo)

  FOO 
  FOO

would instead be 

  USER(173): (print 'foo)
  FOO 
  FOO

or

  USER(174): (progn (format t "FOO~%")
		    (print 'bar))
  FOO

  BAR 
  BAR

would instead be

  USER(174): (progn (format t "FOO~%")
		    (print 'bar))
  FOO
  BAR 
  BAR

and etc. But that's really nitpicking....

Christopher