[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: prin1 / princ vs message ?
From: |
Jean-Christophe Helary |
Subject: |
Re: prin1 / princ vs message ? |
Date: |
Sun, 2 Jul 2017 22:09:38 +0900 |
Tony, Noam,
Thank you very much for the clarifications.
So, since I expect the developer to know the difference between the prin?
collection and message could you tell me if the following is correct:
Instead of using message to replace that code:
(let ((name "JC"))
(prin1 "My name ")
(princ " is ")
(princ name)
(princ ".\n\n"))
It would be better to use something like:
(let ((sentence (format "My name is %s.\n\n)))
(prin1 sentence))
That way I keep the possibility to redirect the output somewhere else while
making the sentence actually maintainable...
Jean-Christophe
> On Jul 2, 2017, at 21:45, Noam Postavsky <address@hidden> wrote:
>
> On Sun, Jul 2, 2017 at 8:21 AM, Jean-Christophe Helary
> <address@hidden> wrote:
>>
>> I am asking that because I am seeing code where standard-output is not set
>> to anything but it's default (the echo area) and still prin1/princ are
>> preferred over message. So, why would a developer chose prin1/princ over
>> message when there is no stream argument (hence, when the output goes to
>> standard output).
>
> Using prin1/princ lets the caller let-bind standard-output to redirect
> the output elsewhere, using message would not allow this.
>
> Otherwise, I think the only practical difference is that prin1/princ
> to the echo area doesn't support message coalescing, e.g.,
> (progn (message "foo") (message "foo")) will show "foo [2 times]" in
> *Messages*, whereas (progn (princ "foo") (princ "foo")) will show
> "foofoo".
- prin1 / princ vs message ?, Jean-Christophe Helary, 2017/07/02
- Re: prin1 / princ vs message ?, Tino Calancha, 2017/07/02
- Re: prin1 / princ vs message ?, Jean-Christophe Helary, 2017/07/02
- Re: prin1 / princ vs message ?, Tino Calancha, 2017/07/02
- Re: prin1 / princ vs message ?, Noam Postavsky, 2017/07/02
- Re: prin1 / princ vs message ?,
Jean-Christophe Helary <=
- Re: prin1 / princ vs message ?, Noam Postavsky, 2017/07/02
- Re: prin1 / princ vs message ?, Tino Calancha, 2017/07/02
- Re: prin1 / princ vs message ?, Jean-Christophe Helary, 2017/07/02
- Re: prin1 / princ vs message ?, Jean-Christophe Helary, 2017/07/02
- Re: prin1 / princ vs message ?, Tino Calancha, 2017/07/02
- Re: prin1 / princ vs message ?, Jean-Christophe Helary, 2017/07/02
- Re: prin1 / princ vs message ?, Philipp Stephani, 2017/07/02
- Re: prin1 / princ vs message ?, Jean-Christophe Helary, 2017/07/02
- (format "Hello %1$S%2$s" 'world "!"), Clément Pit-Claudel, 2017/07/02
- Re: (format "Hello %1$S%2$s" 'world "!"), Jean-Christophe Helary, 2017/07/02