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: Tue, 18 Aug 2015 03:32:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

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

> Barry Margolin <barmar@alum.mit.edu> writes:
>
>> No it doesn't. It looks like it does, but only
>> because sharp-quote just returns the symbol in Emacs
>> Lisp, not a function.
>
> OK.
>
>> The problem is that sharp-quote is just syntactic
>> sugar in Elisp, it doesn't actually do anything
>> different from quote.
>
> This makes it confusing to use.

Not if you realize the above sentence is false.

    (cl-flet ((f () 'local))
      (function f))
    --> (lambda nil (quote local))


>> You don't disable functions, you disable *commands*,
>> and commands are denoted using symbols.
>
> And the symbols look the same as the function's names?

Yes, some functions are named by symbols. 


> And commands are functions, only those "interactive"
> (in Emacs lingo)?

Yes.


> So where does that leave functions? And when (and why)
> are they refered to "as such", i.e. not using symbols
> to denote them?

There are several kinds of function objects:

    (defun f () 'hello)

    (symbol-function 'f) --> (lambda nil (quote hello))

    (symbol-function 'sin) --> #<subr sin>

    (symbol-function 'find-file)  --> #[(filename &optional wildcards)  
                                       "<binary data>" 
                                       [<constants>]
                                       6 1758059
                                       (byte-code "<binary-data>>"
                                       [<constants>] 3)]

    (setf lexical-binding t)
    (let ((x 42))
       (defun g () x))
    (symbol-function 'g) --> (closure ((x . 42) t) nil x)
    (byte-compile 'g)
    (symbol-function 'g) --> #[nil "\300\207" [42] 1]

    
> If there are two different syntaxes those should
> indicate two different things and there should be
> a rule that can be expressed in one sentence when each
> should be used.

See above, they are different.


> Even so, I don't see why this should be dealt with on
> the code-level at all. Why not just refer to functions
> by name and then have the functions that accepts them
> (the names) sometimes deal with those as symbols
> denoting commands, sometimes functions (?), and so on,
> and not bother me with it? And interestingly, that is
> exactly how it has been and there were never any
> troubles until I read here I can't do that.

Because:
- some functions don't have a name at all, and 
- some functions are actually closures, and 
- some functions can escape the lexical environment
  where their name is bound.

And basically, you should learn Common Lisp.

-- 
__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]