[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Real-life examples of lexical binding in Emacs Lisp
From: |
Pascal J. Bourguignon |
Subject: |
Re: Real-life examples of lexical binding in Emacs Lisp |
Date: |
Wed, 17 Jun 2015 12:53:01 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
"Pascal J. Bourguignon" <pjb@informatimago.com> writes:
> ;; and then in some unrelated code in a different file:
>
> (setq lexical-binding nil)
> (let ((scratch-buffer (get-buffer-create "*scratch*")))
> (with-current-buffer scratch-buffer (insert "hello"))
> (some-function "Howdy?")
> (with-current-buffer scratch-buffer
> (buffer-substring (point-min) (point-max))))
Without lexical binding, to try to get some independence from other
functions, you would have to PREFIX ALL THE LOCAL VARIABLES WITH
FUNCTION SPECIFIC PREFIXES!
(defun pjb-package--pjb-example-function ()
(let ((pjb-package--pjb-example-function--scratch-buffer
(get-buffer-create "*scratch*")))
(with-current-buffer pjb-package--pjb-example-function--scratch-buffer
(insert "hello"))
(some-function "Howdy?")
(with-current-buffer pjb-package--pjb-example-function--scratch-buffer
(buffer-substring (point-min) (point-max)))))
And this is only a convention that wouldn't prevent
another-package--evil-function to modify
pjb-package--pjb-example-function--scratch-buffer anyways.
Now look at all the el code arround, and count how many local variables
are named like this!!!
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
- Re: Real-life examples of lexical binding in Emacs Lisp, Marcin Borkowski, 2015/06/14
- Re: Real-life examples of lexical binding in Emacs Lisp, Marcin Borkowski, 2015/06/14
- Re: Real-life examples of lexical binding in Emacs Lisp, Pascal J. Bourguignon, 2015/06/14
- Re: Real-life examples of lexical binding in Emacs Lisp, Jim Diamond, 2015/06/16
- Re: Real-life examples of lexical binding in Emacs Lisp, Emanuel Berg, 2015/06/16
- Re: Real-life examples of lexical binding in Emacs Lisp, Andreas Röhler, 2015/06/17
- Message not available
- Re: Real-life examples of lexical binding in Emacs Lisp, Pascal J. Bourguignon, 2015/06/17
- Re: Real-life examples of lexical binding in Emacs Lisp,
Pascal J. Bourguignon <=
- Re: Real-life examples of lexical binding in Emacs Lisp, Stefan Monnier, 2015/06/17
- Re: Real-life examples of lexical binding in Emacs Lisp, Andreas Röhler, 2015/06/17
- Re: Real-life examples of lexical binding in Emacs Lisp, Tassilo Horn, 2015/06/17
- Message not available
- Re: Real-life examples of lexical binding in Emacs Lisp, Stefan Monnier, 2015/06/17
- Re: Real-life examples of lexical binding in Emacs Lisp, Emanuel Berg, 2015/06/17
- Re: Real-life examples of lexical binding in Emacs Lisp, Pascal J. Bourguignon, 2015/06/17
- Re: Real-life examples of lexical binding in Emacs Lisp, Emanuel Berg, 2015/06/17
- Re: Real-life examples of lexical binding in Emacs Lisp, Udyant Wig, 2015/06/18
- Re: Real-life examples of lexical binding in Emacs Lisp, Emanuel Berg, 2015/06/18
- Re: Real-life examples of lexical binding in Emacs Lisp, Udyant Wig, 2015/06/19