[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Byte compiling and semi-free variables
From: |
Stephen J. Turnbull |
Subject: |
Byte compiling and semi-free variables |
Date: |
Mon, 29 Dec 2008 02:26:23 +0900 |
Lennart Borgman writes:
> If you order definitions top-down in your elisp source files, like this
>
> ;;;; Interactive defuns:
>
> (defun my-fun ()
> (interactive)
> (setq my-internal-var 1) )
>
> ;;;; Internal variables
> (defvar my-internal-var nil)
But that's not top-down. `my-internal-variable' is global, ie, it has
the same scope as `my-fun'.
If `my-internal-variable' is not intended to be global, ie, it is only
accessed in `my-fun', then you could try
(defun my-fun ()
(interactive)
;; The elisp static local wannabe idiom
(eval-when-compile (defvar my-internal-var))
(setq my-internal-var 1))