unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* curious why private variables are rare
@ 2022-11-20  2:07 Samuel Wales
  2022-11-20  3:53 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2022-11-21 12:48 ` Emanuel Berg
  0 siblings, 2 replies; 5+ messages in thread
From: Samuel Wales @ 2022-11-20  2:07 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-10-02 23:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-20  2:07 curious why private variables are rare Samuel Wales
2022-11-20  3:53 ` 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

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).