From: Samuel Wales <samologist@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: curious why private variables are rare
Date: Sat, 19 Nov 2022 19:07:40 -0700 [thread overview]
Message-ID: <CAJcAo8tsy-pFFZ2L2FTO=P71NVsPKDX20KmXnzgO5GdVf9O44A@mail.gmail.com> (raw)
the usual thing is:
(defvar var ...)
(defun fun ...)
even when var is only used by fun. but you could do:
(let ((var ...))
(defun fun ...))
[at least, i /think/ you can do this with similar results from the
perspective of the function, and it wfm. however, i know that there
are multiple interpretations of lexical binding, at least at top
level, and those considerations might apply.]
the most obvious drawback of the latter would probably be convenience
in debugging/inspectability/discoverability. re-using a variable name
could be confusing. other than that and extra indentation, i'm not
sure if there are big drawbacks.
it would limit scope so you don't pollute completion, apropos, etc.
you can eliminate prefix. no stomp on vars.
so i am just curious why the usual thing is usual. is it the above
reasons? or am i missing some bigger things?
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
next reply other threads:[~2022-11-20 2:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-20 2:07 Samuel Wales [this message]
2022-11-20 3:53 ` curious why private variables are rare Stefan Monnier via Users list for the GNU Emacs text editor
2022-11-21 12:52 ` Emanuel Berg
2023-10-02 23:56 ` Samuel Wales
2022-11-21 12:48 ` Emanuel Berg
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='CAJcAo8tsy-pFFZ2L2FTO=P71NVsPKDX20KmXnzgO5GdVf9O44A@mail.gmail.com' \
--to=samologist@gmail.com \
--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.
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).