;;; example-with-lexical-header.el --- -*- lexical-binding: t -*- ;; Copyright (C) 2022, Paul Horton ;; License: GPLv3 ;;; Commentary: ;; Example to illustrate the effects of declaring lexical binding in elisp. ;; ;; Compare the code in this file and its companion file "example-sans-lexical-header.el". ;; Load them and examine the information displayed in buffer "*dynamic vs lexical*". (get-buffer-create "*dynamic vs lexical*") (setq with-lexical-header/sans-defvar "global value") (defun with-lexical-header/sans-defvar () with-lexical-header/sans-defvar) (defvar with-lexical-header/with-defvar "global value") (defun with-lexical-header/with-defvar () with-lexical-header/with-defvar) (let( (with-lexical-header/sans-defvar "local value") (with-lexical-header/with-defvar "local value") ) (pop-to-buffer "*dynamic vs lexical*") (goto-char (point-max)) (insert "\n# Results with lexical binding header\n" " with-lexical-header/sans-defvar contains \t" with-lexical-header/sans-defvar "\n" "(with-lexical-header/sans-defvar) returns: \t" (with-lexical-header/sans-defvar) "\n" " with-lexical-header/with-defvar contains \t" with-lexical-header/with-defvar "\n" "(with-lexical-header/with-defvar) returns: \t" (with-lexical-header/with-defvar) "\n" ) ) ;;; example-with-lexical-header.el ends here