all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: symbols and cells
Date: Thu, 15 May 2014 22:16:06 +0200	[thread overview]
Message-ID: <87ppje23y1.fsf@web.de> (raw)
In-Reply-To: 20140515091005.52cc1897@voltron.arsc.edu

Christopher Howard <cmhoward2@alaska.edu> writes:

> I'm still working through the earlier parts of the Elisp
> documentation, but I am curious: How does one define the variable cell
> and function cell for an /uninterned/ symbol? The docs indicate you
> can do this:
>
> (defvar sym (make-symbol "foo"))
>
> But how do you add a function or variable value to foo without
> interning it?

"Interning it" is a bit imprecise, since an uninterned symbol can't be
interned, only the string "foo" could be interned, and the result would be
different from any uninterned symbol of the same name.

You can use the functions `set' to set the value cell and `fset' to set
the function cell.

An even better question is: how would you call this uninterned symbol as a
function...?

Using uninterned symbols is almost only useful when macros are involved.
You should not care too much about them until you use macros.

> On a related note, I'm curious about this perverse construction:
>
> (defvar sym1 (lambda (n) (+ 1 n)))
>
> Is it actually possible to call the the lambda somehow?

Of course - with `funcall'.  And it's not perverse at all in Lisp where
functions are first class objects.

That Elisp is Lisp 2 (symbols have separate value and function cells)
doesn't mean that you can't bind a variable to a function (i.e., set the
value cell of a symbol to a function).  On the contrary, this is quite
normal.


Michael.




  reply	other threads:[~2014-05-15 20:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15 17:10 symbols and cells Christopher Howard
2014-05-15 20:16 ` Michael Heerdegen [this message]
     [not found] <mailman.1410.1400173825.1147.help-gnu-emacs@gnu.org>
2014-05-15 18:07 ` Pascal J. Bourguignon

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

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

  git send-email \
    --in-reply-to=87ppje23y1.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=help-gnu-emacs@gnu.org \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.