TFAE:
(defun z0 (x &rest y) (format t "~?" x y))
(defun z1 (x &rest y) (apply #'format t x y))
which one is prefered?
I tried to compile and disassemble, and it looks like ACL and CLISP
prefer `z1' while CMUCL prefers `z0'.
--
Sam Steingold (http://www.goems.com/~sds) running RedHat6.0 GNU/Linux
Micros**t is not the answer. Micros**t is a question, and the answer is Linux,
(http://www.linux.org) the choice of the GNU (http://www.gnu.org) generation.
You can have it good, soon or cheap. Pick two...
In article <··············@eho.eaglets.com>,
Sam Steingold <···@goems.com> wrote:
>TFAE:
>
>(defun z0 (x &rest y) (format t "~?" x y))
>(defun z1 (x &rest y) (apply #'format t x y))
>
>which one is prefered?
Whichever is clearer under the circumstances. If the only thing in the
format string is "~?" I would recommend z1. "~?" is most useful when it's
embedded within a format string; see the FORMAT-ERROR example in CLTL2.
>I tried to compile and disassemble, and it looks like ACL and CLISP
>prefer `z1' while CMUCL prefers `z0'.
What do you mean by "prefer" in this respect?
--
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.
>>>> In message <···················@burlma1-snr2>
>>>> On the subject of "Re: format "~?""
>>>> Sent on Mon, 10 May 1999 21:03:41 GMT
>>>> Honorable Barry Margolin <······@bbnplanet.com> writes:
>> In article <··············@eho.eaglets.com>,
>> Sam Steingold <···@goems.com> wrote:
>>
>> >I tried to compile and disassemble, and it looks like ACL and CLISP
>> >prefer `z1' while CMUCL prefers `z0'.
>>
>> What do you mean by "prefer" in this respect?
the disassembly is shorter (=> faster execution?)
--
Sam Steingold (http://www.goems.com/~sds) running RedHat6.0 GNU/Linux
Micros**t is not the answer. Micros**t is a question, and the answer is Linux,
(http://www.linux.org) the choice of the GNU (http://www.gnu.org) generation.
When we write programs that "learn", it turns out we do and they don't.
In article <··············@eho.eaglets.com>,
Sam Steingold <···@goems.com> wrote:
>>>>> In message <···················@burlma1-snr2>
>>>>> On the subject of "Re: format "~?""
>>>>> Sent on Mon, 10 May 1999 21:03:41 GMT
>>>>> Honorable Barry Margolin <······@bbnplanet.com> writes:
> >> In article <··············@eho.eaglets.com>,
> >> Sam Steingold <···@goems.com> wrote:
> >>
> >> >I tried to compile and disassemble, and it looks like ACL and CLISP
> >> >prefer `z1' while CMUCL prefers `z0'.
> >>
> >> What do you mean by "prefer" in this respect?
>
>the disassembly is shorter (=> faster execution?)
But don't forget that when FORMAT itself notices the ~? sequence, it's
going to do something like (apply format this-arg next-arg) internally. So
that code will be executed in the z0 case, just from somewhere else.
--
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.
Sam Steingold <···@goems.com> writes:
> TFAE:
>
> (defun z0 (x &rest y) (format t "~?" x y))
> (defun z1 (x &rest y) (apply #'format t x y))
>
> which one is prefered?
I think it doesn't matter much. I might prefer the former because
it's likely to be less object code, but I think it's mostly just a
personal style thing.
> I tried to compile and disassemble, and it looks like ACL and CLISP
> prefer `z1' while CMUCL prefers `z0'.
Ask the same question about something where you don't have control of
what function gets called. Consider:
(defun frob (x)
(make-instance 'simple-condition :format-control "~?" :format-arguments x))
That's hard to rewrite using apply unless you want to use
:format-control "~A" :format-arguments (list (apply #'format ...))
but that has problems for other reasons [to do with how much info you
find in the debugger later if you get the condition object and want to
inspect the data that made it up].