help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

curious why private variables are rare


From: Samuel Wales
Subject: curious why private variables are rare
Date: Sat, 19 Nov 2022 19:07:40 -0700

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]