emacs - Local to `let` versus local to a function -
in another question regarding local variable definitions in elisp, both respondents advise let
appropriate , emphasize not define variable local function. variable local let
statement.
what distinction between local let
, local function? there construct define variable scope of function?
the function using let
statement looks this:
(defun test-search (string) "searches string in document. displays message 'found!' or 'not found...'. places point after word when found; fixed otherwise." (interactive "senter search word: ") (let ((found (save-excursion (beginning-of-buffer) (search-forward string nil t nil)))) (if found (progn (goto-char found) (message "found!")) (message "not found..."))))
since let
makes whole body of function in example, "variables local let" indistinguishable "variables local function".
for reason, no there no separate construct introduce variables local function. let
construct, can used variables valid on whole function, or variables valid on small subset, depending on place let
.
Comments
Post a Comment