[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: shorter form of frequently-seen lisp idiom?
From: |
David Kastrup |
Subject: |
Re: shorter form of frequently-seen lisp idiom? |
Date: |
Sun, 20 Feb 2005 00:55:53 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
August <fusionfive@comhem.se> writes:
> On lör, 2005-02-19 at 19:43 +0100, David Kastrup wrote:
>> Joe Corneli <jcorneli@math.utexas.edu> writes:
>>
>> > Is there a shorter way to concatenate a list of strings
>> > than this?
>> >
>> > (eval (append (list 'concat) list-of-strings))
>> >
>> > Or more generally,
>> >
>> > (eval (append (list 'function-that-acts-on-foos) list-of-foos))
>>
>> (apply #'concat list-of-strings)
>>
>
> What's the purpose of the hash sign? `(apply 'concat
> list-of-strings)' works too.
'concat is short for (quote concat), #'concat is short for
(function concat).
It tells the byte compiler that it is ok to compile the function. For
example,
'(lambda nil (if))
is a perfectly valid list and if used in function context even in
compiled Elisp files, will be evaled the slow way at run time.
#'(lambda nil (if)) in contrast gets byte-compiled (and the byte
compiler will probably barf).
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Re: shorter form of frequently-seen lisp idiom?, Stefan Monnier, 2005/02/22
Re: shorter form of frequently-seen lisp idiom?, Oliver Scholz, 2005/02/22
RE: shorter form of frequently-seen lisp idiom?, Drew Adams, 2005/02/22