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

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

Re: What is the :eval form ?


From: Thien-Thi Nguyen
Subject: Re: What is the :eval form ?
Date: Sat, 09 Jun 2012 10:34:02 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

() Richard Riley <rileyrg@gmail.com>
() Sat, 09 Jun 2012 08:40:44 +0200

   Is that also true in a function call? 

   ,----
   |   (notifications-notify  :title "Wazzup!?" :message message))
   `----

   title and message are not keywords here. 

   Or is the keyword "symbol" here?

In Emacs Lisp keywords and symbols are not disjoint.
A keyword is a symbol whose name begins with colon.
That's all (conceptually).

  ;; -*- emacs-lisp -*-
  (symbolp 'foo)
  t
  
  (symbolp :foo)
  t
  
  (keywordp 'foo)
  nil
  
  (keywordp :foo)
  t

In this *scratch* excerpt, we see that relationship
and note that all occurances are "in a function call"
(i presume to mean "arg to a function"), the functions
being ‘symbolp’ and ‘keywordp’.

But design and implementation are likewise not disjoint:

In the prior example, ‘notifications-notify’ is called
with four args, the even-indexed keywords, the odd-indexed
a string and whatever ‘message’ happens to be.

If you instrument (advise) ‘notifications-notify’ to call
‘type-of’ on each of the args it receives, you will find
that ‘type-of’ is not so smart:

  (type-of 'foo)
  symbol
  
  (type-of :foo)
  symbol

You might be tempted, then, to write:

  (defun excruciatingly-correct-type-of (object)
    (let ((guess (type-of object)))
      (case guess
        (symbol (if (char-equal ?: (aref (symbol-name object) 0))
                    'keyword
                  guess))
        (t guess))))
  
  (excruciatingly-correct-type-of 'foo)
  symbol
  
  (excruciatingly-correct-type-of :foo)
  keyword

Or not.  Personally, i stressed about this a while back but now
have mellowed out a bit.  Willful ignorance tastes different once
you go around the circle (at least once :-D).



reply via email to

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