unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Robert Thorpe <rt@robertthorpeconsulting.com>
To: Thorsten Jolitz <tjolitz@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Whats wrong with this defcustom?
Date: Tue, 29 Jul 2014 01:46:10 +0100	[thread overview]
Message-ID: <87d2cprnzh.fsf@robertthorpeconsulting.com> (raw)
In-Reply-To: <87vbqhull4.fsf@gmail.com> (message from Thorsten Jolitz on Tue, 29 Jul 2014 01:09:43 +0200)

Thorsten Jolitz <tjolitz@gmail.com> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
...
>
> Ok, precision matters, so a quoted symbol is at the same time an
> unquoted *expression* that returns the symbol itself ... while an unquoted symbol
> in an unquoted *expression* that tries to return the symbols value (as a
> variable) ... (?)


Apologies if I explain things you already know.  See below:
*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (setq bar 4)
4
ELISP> (setq foo bar)
4
ELISP> foo
4
ELISP> bar
4
ELISP> (setq foo 'bar)
bar
ELISP> foo
bar
ELISP> bar
4

Think about setq....  If you want to set foo to the symbol bar then you
have to quote it.  Similarly, in defcustom if you want the STANDARD to
be a symbol then you have to quote it, so quoting "notes" is right.  On
the other hand the whole "'choice ..." expression is quoted.  It's a
data structure, a little list/tree made up of strings and symbols.  The
bit in the docstring is telling you not to quote anything except
symbols.

This may help...  Last week I replied to a question about symbols and
explained what they are.  Sometimes the lisp interpreter evaluates and
sometimes it doesn't, that confuses things.  I wrote: "If we have a
function call: (foo bar 'baz) then lisp treats each of these symbols
differently.  It finds the function slot for foo because that's the
first symbol, it finds the variable slot for bar because it's not first.
Finally, 'baz returns the symbol itself.  To be more careful: (quote
baz) returns a list containing the symbol, which evaluates to the
symbol".  That applies to functions, other things can be different.

Imagine we have a lisp interpreter that works on lisp lists.  It takes a
tree (a lisp list) and evaluates it (the "eval" function) by looking at
the first argument and figuring out what to do.  Some "special forms"
are dealt with directly.  For other things the interpreter finds the
corresponding function.  If you think about this it needs to decide how
to deal with arguments.  They can be "unevalled", the relevant fragment
of the list can be used as-is.  Or it can be "evalled" in which case a
recursive call to the eval function is needed.  In that case a list
would be interpreted as a function call and a sole symbol as a variable
reference.  Does the lisp programmer need to deal with both unevalled
and evalled type arguments?  Not really, a special-form can be provided
to switch between the two.  The special-form "Quote" takes its arguments
unevalled and simply returns them; '(something) is just an abbreviation
for (quote something).

As well as quote, there are a few built-in special forms that work that
way.  There are also macros which operate directly on lists.  They get
lists from the reader before evaluation begins, then they transform
them.

For example, "eval-when-compile" is a macro.  It takes an argument BODY
which is unquoted.  On the other hand, "eval-after-load" is a function
it takes two arguments FILE and FORM.  Since it's a function FORM must
be quoted.  Because eval-after-load is a function it must call eval
explicitly to deal with FORM.  The line in defcustom's documentation
about not quoting is there to say that defcustom behaves like
"eval-when-compile" not like "eval-after-load".

BR,
Robert Thorpe



  reply	other threads:[~2014-07-29  0:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-26 10:55 Whats wrong with this defcustom? Thorsten Jolitz
2014-07-28  8:58 ` Tassilo Horn
2014-07-28 10:06   ` Thorsten Jolitz
2014-07-28 22:11   ` [BUG] in defcustom docstring (was Re: Whats wrong with this defcustom?) Thorsten Jolitz
2014-07-28 22:33   ` Whats wrong with this defcustom? Stefan Monnier
2014-07-28 23:09     ` Thorsten Jolitz
2014-07-29  0:46       ` Robert Thorpe [this message]
2014-07-29  2:06         ` Thien-Thi Nguyen
2014-07-29 23:55           ` Robert Thorpe
2014-07-29  8:19         ` Thorsten Jolitz
     [not found]   ` <mailman.6168.1406585492.1147.help-gnu-emacs@gnu.org>
2014-07-29 16:48     ` [BUG] in defcustom docstring (was Re: Whats wrong with this defcustom?) Christoph Wedler
2014-07-28 13:17 ` Whats wrong with this defcustom? Sebastian Wiesner
2014-07-28 13:54   ` Thorsten Jolitz
     [not found] <mailman.6065.1406372149.1147.help-gnu-emacs@gnu.org>
2014-07-26 12:58 ` Olve
2014-07-26 13:32   ` Thorsten Jolitz
     [not found] <mailman.6258.1406678132.1147.help-gnu-emacs@gnu.org>
2014-07-30  0:34 ` Emanuel Berg
2014-07-30  1:32   ` Robert Thorpe
     [not found] <mailman.6265.1406683969.1147.help-gnu-emacs@gnu.org>
2014-07-30  2:18 ` Emanuel Berg
2014-07-30  2:25   ` Emanuel Berg
2014-07-30 22:32   ` Robert Thorpe
     [not found] <mailman.6309.1406759543.1147.help-gnu-emacs@gnu.org>
2014-07-30 22:50 ` Emanuel Berg
2014-07-31 21:56   ` Robert Thorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d2cprnzh.fsf@robertthorpeconsulting.com \
    --to=rt@robertthorpeconsulting.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=tjolitz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).