help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to quote a list of functions?


From: Pascal J. Bourguignon
Subject: Re: How to quote a list of functions?
Date: Mon, 17 Aug 2015 02:06:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Emanuel Berg <embe8573@student.uu.se> writes:

> John Mastro <john.b.mastro@gmail.com> writes:
>
>> I think you have this metaphor backward; all I said
>> was that sharp-quote can be helpful (like
>> indentation), not that you should be compelled to
>> use it.
>>
>> Pascal's point (that the sameness between `quote'
>> and `function' in Emacs Lisp is an implementation
>> detail which, at least in principal, could change)
>> is perhaps stronger, but he's not saying that Emacs
>> Lisp should change to force you to use `quote' and
>> `function' differently.
>
> This discussion is by now nothing but confusing.
>
> The one advantage we have heard is - if it is used,
> the compiler will tell you if the function is defined,
> so it is a safety net for typos and mix-ups.
>
> The disadvantages are:
>
>     - Ugly syntax; and, one less char on that line
>       available.
>     
>     - Not clear when to use it (as this discussion
>       shows).
>
>     - Until you get used to it, you have to stop and
>       think if it should be used or not. You don't
>       want to think about that, but of the problem
>       that you are set to solve - also, the context
>       and function name should already communicate
>       this to you, and with this syntax you may be
>       tempted to be more sloppy with that.

It's quite simple.

When you want a function given a name, you use (function NAME) or #'NAME
which reads equally.

When you want a symbol, you use (quote SYMBOL) or 'SYMBOL which reads
equally.

Accidentally, on the current GNU emacs lisp implementation, 
(function X) and (quote X) return the same thing, the symbol X,

so if you make a mistake and write #'NAME when you need a symbol, you
won't notice it (unless you compile the code and no function named NAME
exist, 

and if you make the opposite mistake, and write 'NAME instead of #'NAME,
then since 1- emacs lisp doesn't have local lexical functions (flet is
just a kludge, not the real thing), and 2- symbols designate the
function they name, ultimately for apply (which is the primitive called
by funcall and all the other high order functions), then it doesn't make
a difference.

Check this AI Koan:
https://en.wikipedia.org/wiki/Hacker_koan#Enlightenment

The problem is not what you do, the problem is what you intend to do.

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk




reply via email to

[Prev in Thread] Current Thread [Next in Thread]