emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eev 6664769: Added the sections 1, 2, and 3 to `(find-l


From: ELPA Syncer
Subject: [elpa] externals/eev 6664769: Added the sections 1, 2, and 3 to `(find-lexical-intro)'.
Date: Fri, 13 Aug 2021 22:57:08 -0400 (EDT)

branch: externals/eev
commit 666476975ed6db1a7341995f1f57087af3c9f634
Author: Eduardo Ochs <eduardoochs@gmail.com>
Commit: Eduardo Ochs <eduardoochs@gmail.com>

    Added the sections 1, 2, and 3 to `(find-lexical-intro)'.
---
 VERSION       |   4 +-
 eev-intro.el  | 129 +++++++++++++++++++++++++++++++++++++++-------------------
 eev-tlinks.el |   8 ++--
 3 files changed, 93 insertions(+), 48 deletions(-)

diff --git a/VERSION b/VERSION
index 37b6ff7..ef91aca 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-Sat Aug 14 00:16:32 GMT 2021
-Fri Aug 13 21:16:32 -03 2021
+Sat Aug 14 02:49:07 GMT 2021
+Fri Aug 13 23:49:07 -03 2021
diff --git a/eev-intro.el b/eev-intro.el
index 74e2e54..43a2c5b 100644
--- a/eev-intro.el
+++ b/eev-intro.el
@@ -13607,67 +13607,114 @@ modes to compare the results.
 
 
 
+(The rest of this tutorial is just a first draft)
 
-(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\")
-     (find-eev \"eev-eval.el\" \"tools\" \"ee-eval-lexical\")
-     (find-efunctiondescr 'eval)
-
-Try to evaluate this sexp with `M-e' and with `M-1 M-1 M-e':
+1. `lambda' and `function'
+==========================
+See: (find-elnode \"Anonymous Functions\" \"Macro: lambda\")
+     (find-elnode \"Anonymous Functions\" \"Special Form: function\")
+     (find-elnode \"Anonymous Functions\" \"Special Form: function\" 
\"converted\")
 
   (let ((x 42))
-    (defun foo () (* x x))
-    (symbol-function 'foo))
+    (lambda () x)
+    )
 
+  (let ((x 42))
+    (function 
+      (lambda () x)
+      )
+    )
 
 
 
-1. Creating closures
+2. How closures work
 ====================
-Long form:
-
-  (eval '(let ((x 42)) (defun foo () (* x x))) 'lexical)
-  (eval '(let ((x 42)) (defun foo () (* x x))) nil)
-  (symbol-function 'foo)
+See: (find-elnode \"Dynamic Binding\" \"defun getx\")
+     (find-elnode \"Lexical Binding\" \"defun getx\")
+     (find-elnode \"Void Variables\")
 
-Short form:
+  (let ((x 20))
+    (defun getx () x)
+    )
 
-  (let ((x 42))
-    (defun foo () (* x x))
-    (symbol-function 'foo))
+  (makunbound 'x)
+  (setq x 99)
+  (getx)
+  (let ((x 42)) (getx))
+ 
 
-Even shorter:
 
-  (let ((x 42))
-    (function (lambda foo () (* x x))))
 
+3. `get/set'
+============
+;; These fsets work as defuns.
+;; See: (find-elnode \"Function Cells\")
 
+(fset 'foo (lambda () 20))
+(fset 'foo (lambda () 42))
+(foo)
 
+;; This is the only sexp in this block that needs
+;; to be run in lexical binding mode.
+;;
+(defun get/set0 ()
+  \"Return a list with a `getter' closure and a `setter' closure.
+The getter and the setter share the same lexical environment -
+which means that they operate on the same `x'.
+Different calls to this function generate getters and setters
+with independent lexical environments - which means that they
+operate on independent `x's.
+This defun need to be executed in lexical binding mode.\"
+  (let* ((x nil))
+    (list (lambda () x)
+          (lambda (newvalue) (setq x newvalue)))))
+
+(defun get/set (getter setter)
+  \"Define a SETTER and a GETTER that operate on the same variable.
+SETTER and GETTER are symbols: names of functions. The variable
+lives in a lexical environment that is shared by both the GETTER
+and the SETTER. Each call to this function generates a different
+lexical environment.\"
+  (let ((gs (get/set0)))
+    (fset getter (nth 0 gs))
+    (fset setter (nth 1 gs))))
+
+;; Check that geta/seta and getb/setb operate on different
+;; variables:
+;;
+(get/set 'geta 'seta)
+(get/set 'getb 'setb)
+(symbol-function 'geta)
+(symbol-function 'getb)
+(symbol-function 'seta)
+(symbol-function 'setb)
+(seta 20)
+(setb 42)
+(geta)
+(getb)
+
+
+;; Check that geta/seta use the same lexical environment
+;; and that getb/setb use a second lexical environment.
+;; See: (find-elnode \"Closures\")
+
+          (symbol-function 'seta)
+     (cdr (symbol-function 'seta))
+(car (cdr (symbol-function 'seta)))
+
+(eq
+  (cadr (symbol-function 'geta))
+  (cadr (symbol-function 'seta))
+  )
 
-2. `letxgetx'
-=============
-See: (find-elnode \"Dynamic Binding\" \"defun getx\")
-     (find-elnode \"Lexical Binding\" \"defun getx\")
-     (find-elnode \"Void Variables\")
+(eq
+  (cadr (symbol-function 'getb))
+  (cadr (symbol-function 'setb))
+  )
 
-  (makunbound   'x)
-  (defun getx () x)
-                                             (getx)
-                                (let ((x 1)) (getx))
-             (defun letxgetx () (let ((x 1)) (getx)))
-                   (letxgetx)
-  (symbol-function 'letxgetx)
-  
 
 
 " pos-spec-list)))
diff --git a/eev-tlinks.el b/eev-tlinks.el
index f18c02d..5db38ee 100644
--- a/eev-tlinks.el
+++ b/eev-tlinks.el
@@ -19,7 +19,7 @@
 ;;
 ;; Author:     Eduardo Ochs <eduardoochs@gmail.com>
 ;; Maintainer: Eduardo Ochs <eduardoochs@gmail.com>
-;; Version:    20210709
+;; Version:    20210813
 ;; Keywords:   e-scripts
 ;;
 ;; Latest version: <http://angg.twu.net/eev-current/eev-tlinks.el>
@@ -47,10 +47,7 @@
 
 ;; NOTE (written in 2019mar05): some of the functions here are very
 ;; old and ugly and I haven't used them in ages. They will be deleted
-;; in the next few months.
-
-;; (find-efunctiondescr 'ee-upload-links)
-;; (find-eev "eev-wrap.el" "eewrap-eewrap")
+;; in the next few (or many) months.
 
 
 
@@ -2364,6 +2361,7 @@ This function is used by `ee-0x0-upload-region'."
      (find-efunction 'find-0x0-links)
      ""
      ,(ee-template0 "\
+{url}
 (find-wget \"{url}\")
 (find-wget-elisp \"{url}\")
 ")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]