all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

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.