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 05:04:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Emanuel Berg <address@hidden> writes:

> "Pascal J. Bourguignon" <address@hidden>
> writes:
>
>> put doesn't take functions and neither does it take
>> function designators.
>
> But it does accept functions, as that piece of code
> shows, so the sharp quote syntax is even more
> confusing/tedious/error-prone as it separates
> functions from symbols, only that shouldn't always be
> done, as it depends on the function that gets the
> symbols (or functions as symbols) as well!
>
> It is very much to think about compared to just
> typing:
>
>     ;; enable commands
>     (put 'upcase-region    'disabled   nil)
>     (put 'downcase-region  'disabled   nil)
>     (put 'erase-buffer     'disabled   nil)
>     (put 'suspend-frame    'disabled   t  )
>
> Here, everyone immediately understands that
> `upcase-region' is a function and that isn't disabled
> anymore. 

NO!  This is the point exactly!

upcase-region is NOT a function.  
It is a symbol that _designates_ a function.

You could as well add a disabled key on the plist of a symbol that
doesn't designate any function.

You could use this key for something else, for example, here I "disable"
a variable:

   (defvar smurf 42)
   (defun smurf ()
     (unless (get 'smurf 'disabled)
        smurf))

   (put 'smurf 'disabled t)
   (smurf) ; --> nil

   (put 'smurf 'disabled nil)
   (smurf) ; --> 42


To begin with, what such put expression do, is not to disable functions,
but to "disable" commands (which are some kind of functions).  But this
is done by way of the symbol designating the command, and assuming some
function somewhere _interprets_ this property attached to that _symbol_.
Above it was my function named by the symbol smurf that interpreted it
for a variable named by the symbol smurf.

   (defun smurf ()
     (interactive)
     (message "Smurfed!"))
   (setf (symbol-function 'azrael) (symbol-function 'smurf))
   (put 'smurf 'disabled t)
   (smurf)  ; --> "Smurfed!"
   (azrael) ; --> "Smurfed!"
   M-x smurf RET --> "You have typed RET, invoking a disabled command…"
   M-x azrael RET and you get "Smurfed!" in the *Message* buffer and echo area.

There is a single function object for two symbols designating it:

   (eq (symbol-function 'smurf) (symbol-function 'azrael)) ; --> t

This demonstrate clearly that the mechanism to disable command is not
related to the command (or function), but to the symbol naming the
command.


> The special syntax for functions, which
> shouldn't even be used, would, if used, not clarify
> that one bit in my eyes/fingers.

Of course.


>> The thing is that the implementation of those
>> "notions" or "data abstractions" that are _symbols_,
>> _functions_ and _function designator_ can, did, and
>> will change, across time and space (space being
>> different lisp implementations).
>>
>> On the other hand, the "functional abstractions"
>> such as put don't change.
>
> I never worry what will happen. When it does, I'll
> make it work, then. People always tells me my code
> will break, but it never did. Or maybe it did and
> I fixed it, I don't know.

Of course, it depends on how many successive versions of OS and
platforms you had to pass thru.  All I can say, is that an application
that I wrote on MacOS worked perfectly thru all versions of MacOS till
the version 9, while most other developers were quite surprised to see
they had to patch their application each time a new version of the
system was released.  Either you respect the contract (specifications),
or you don't and you will suffer.

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