From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: How to distinguish gobal and local variables in elisp?
Date: Thu, 21 Sep 2006 13:51:13 -0600 [thread overview]
Message-ID: <eeuqgq$msi$1@sea.gmane.org> (raw)
In-Reply-To: <eeukg4$3vc$1@news.yaako.com>
jronald wrote:
> The question comes from setq.
> Usually, setq appears in a file without in any parentheses.
> Does it mean that it awlays set the global varaible then? Or what's a local
> variable in lisp?
Emacs Lisp is dynamically scoped (like most older Lisp dialects, and
unlike most newer dialects). That means that a variable may be
referenced outside the lexical scope that declares it. For example:
(setq foo 0)
;; At this point, foo has only a global binding, to 0.
(defun bar ()
(setq foo 2))
;; When bar is called, it will update foo's global binding, unless it is
;; shadowed by a local binding.
(let ((foo 1))
;; For the duration of the let form, foo also has a local binding.
;; At this point, its local value is 1.
(bar)
;; Now foo's local value is 2, but its global value is still 0.
)
;; And now only the global binding exists, so foo's value is 0.
--
Kevin
next prev parent reply other threads:[~2006-09-21 19:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-21 18:09 How to distinguish gobal and local variables in elisp? jronald
2006-09-21 18:54 ` Pascal Bourguignon
2006-09-21 19:51 ` Kevin Rodgers [this message]
2006-09-21 20:13 ` Xavier Maillard
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='eeuqgq$msi$1@sea.gmane.org' \
--to=ihs_4664@yahoo.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).