[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eev 504ba89: Added a section "0. How to use this" to `(
From: |
ELPA Syncer |
Subject: |
[elpa] externals/eev 504ba89: Added a section "0. How to use this" to `(find-lexical-intro)'. |
Date: |
Fri, 13 Aug 2021 20:57:08 -0400 (EDT) |
branch: externals/eev
commit 504ba89275a1e8f0a52d6fb667ab286ac7d59c89
Author: Eduardo Ochs <eduardoochs@gmail.com>
Commit: Eduardo Ochs <eduardoochs@gmail.com>
Added a section "0. How to use this" to `(find-lexical-intro)'.
---
VERSION | 4 +-
eev-intro.el | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
eev.el | 2 +-
3 files changed, 119 insertions(+), 4 deletions(-)
diff --git a/VERSION b/VERSION
index c845d25..37b6ff7 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-Fri Aug 13 05:54:51 GMT 2021
-Fri Aug 13 02:54:51 -03 2021
+Sat Aug 14 00:16:32 GMT 2021
+Fri Aug 13 21:16:32 -03 2021
diff --git a/eev-intro.el b/eev-intro.el
index a052010..74e2e54 100644
--- a/eev-intro.el
+++ b/eev-intro.el
@@ -19,7 +19,7 @@
;;
;; Author: Eduardo Ochs <eduardoochs@gmail.com>
;; Maintainer: Eduardo Ochs <eduardoochs@gmail.com>
-;; Version: 20210529
+;; Version: 20210813
;; Keywords: e-scripts
;;
;; Latest version: <http://angg.twu.net/eev-current/eev-intro.el>
@@ -13500,8 +13500,123 @@ See:
+
+0. How to use this
+==================
+Usually people select between lexical binding and dynamic binding
+by putting their functions that use lexical binding in files with
+a \"-*- lexical-binding:t -*-\" in their first line, like this:
+
+ (find-efile \"play/tetris.el\" \"lexical-binding:t\")
+
+See:
+
+ (find-elnode \"Using Lexical Binding\")
+ (find-elnode \"Using Lexical Binding\" \"first line\")
+
+Here we will do something much more low-level. `(eval CODE)'
+and `(eval CODE nil)' both eval CODE using dynamic binding,
+but `(eval CODE t)' and `(eval CODE 'lexical)' eval CODE using
+lexical binding. In dynamic binding all `defun's generate
+lambdas, but in lexical binding some `defun's generate closures.
+You can test this by running the four sexps below with `M-e' -
+the `(eval ... 'lexical)' stores a closure in the function cell
+of `foo':
+
+ (eval '(let ((x 42)) (defun foo () (* x x))) nil)
+ (symbol-function 'foo)
+
+ (eval '(let ((x 42)) (defun foo () (* x x))) 'lexical)
+ (symbol-function 'foo)
+
+We will also use another technique, based on `M-e', for making
+code eval-able in both dynamic binding mode and lexical binding
+mode.
+
+Let me list some facts...
+
+ 1) dynamic binding is still the current default, but it is
+ being phased out and may be declared obsolete in a few years
+ - AND EVEN KILLED COMPLETELY, despite the complaints of the
+ many people who love it, like me;
+
+ 2) `M-e' goes to the end of the line, reads the sexp before
+ point, and `eval's it;
+
+ 3) `M-e' _sort of_ emulates `C-e C-x C-e', but `C-x C-e'
+ doesn't run a plain `eval' - it runs a function based on
+ `eval' that has lots of bells and whistles, and that is too
+ complex for my tiny brain. Take a look at its code:
+
+ (eek \"M-h M-k C-x C-e ;; eval-last-sexp\")
+ (find-efunctiondescr 'eval-last-sexp)
+ (find-efunction 'eval-last-sexp)
+
+ 4) `C-x C-e' uses the buffer-local variable `lexical-binding'
+ to decide whether it should use dynamic or lexical binding,
+ while `M-e' does not. Try to eval the sexps below with a
+ series or `C-e C-x C-e's:
+
+ (setq-local lexical-binding t)
+ (let ((x 42)) (defun foo () (* x x)))
+ (symbol-function 'foo)
+
+ (setq-local lexical-binding nil)
+ (let ((x 42)) (defun foo () (* x x)))
+ (symbol-function 'foo)
+
+ You will see that the first block generates a closure and
+ the second does not. If you try to execute those six sexps
+ with `M-e's you'll get lambdas in both blocks.
+
+ 5) I chose to use a simple `eval' without the second argument
+ in the plain `M-e' because: a) it is simpler to understand,
+ b) it is simpler to explain to beginners, and b) people can
+ change it by redefining this function:
+
+ (find-eev \"eev-eval.el\" \"arg-variants\"
\"ee-eval-last-sexp-default\")
+
+ 6) `M-e' supports numeric prefixes that select alternate
+ actions - for example, `M-0 M-e' highlights the sexp instead
+ of executing it - and it's easy to add new alternate
+ actions. See:
+
+ (find-eev \"eev-eval.el\" \"ee-eval-last-sexp\")
+ (find-eev \"eev-eval.el\" \"arg-variants\")
+
+ 7) `M-1 M-1 M-e' (or: `M-11e') uses `(eval ... 'lexical)'
+ instead of the plain `eval'. See:
+
+ (find-efunction 'ee-eval-last-sexp-default)
+ (find-efunction 'ee-eval-last-sexp-11)
+ (find-efunction 'ee-eval-lexical)
+
+ Try to execute the 4-line sexp below with both `M-e' and
+ `M-11e':
+
+ (let ((x 42))
+ (defun foo () (* x x))
+ (symbol-function 'foo)
+ )
+
+In the rest of this tutorial I will suppose that the reader knows
+how to use `M-e' to eval sexps in the \"old\" dynamic binding
+mode and `M-11e' to eval sexps in new lexical binding mode, and
+knows how to run code blocks in BOTH dynamic and lexical binding
+modes to compare the results.
+
+
+
+
+(The rest of this tutorial will be rewritten)
+
+
+
+
0. `ee-eval-lexical'
====================
+
+
See: (find-eev \"eev-eval.el\" \"ee-eval-last-sexp\")
(find-eev \"eev-eval.el\" \"ee-eval-last-sexp\" \"11:\")
(find-eev \"eev-eval.el\" \"tools\")
diff --git a/eev.el b/eev.el
index e3fff18..0b9abf6 100644
--- a/eev.el
+++ b/eev.el
@@ -6,7 +6,7 @@
;; Package-Requires: ((emacs "24.4"))
;; Keywords: lisp e-scripts
;; URL: http://angg.twu.net/#eev
-;; Version: 20210808
+;; Version: 20210813
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/eev 504ba89: Added a section "0. How to use this" to `(find-lexical-intro)'.,
ELPA Syncer <=