[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Naming FCRs
From: |
Tomas Hlavaty |
Subject: |
Re: Naming FCRs |
Date: |
Thu, 30 Dec 2021 11:15:17 +0100 |
On Thu 30 Dec 2021 at 09:43, <tomas@tuxteam.de> wrote:
> Possibly because it diverges somewhat from the canonical meaning of
> "closure" -- it might confuse people.
I don't think so. Lisps usually expose a way to see the closed over
variables, so in reality, there is no such thing as "closures that don't
permit access".
You can do that in Emacs right now (maybe not portably across different
compiler backends):
ELISP> (defun foo (a b) (lambda (c) (+ a b c)))
foo
ELISP> (foo 3 5)
(closure
((b . 5)
(a . 3)
t)
(c)
(+ a b c))
ELISP> (defun faz (a b) (lambda (c) (error "a=%d b=%d" a b)))
faz
ELISP> (setq baz (faz 3 5))
(closure
((b . 5)
(a . 3)
t)
(c)
(error "a=%d b=%d" a b))
ELISP> (funcall baz 13)
*** Eval error *** a=3 b=5
ELISP> (setq debug-on-error t)
t
ELISP> (funcall baz 13)
Debugger entered--Lisp error: (error "a=3 b=5")
signal(error ("a=3 b=5"))
error("a=%d b=%d" 3 5)
(closure ((b . 5) (a . 3) t) (c) (error "a=%d b=%d" a b))(13)
funcall((closure ((b . 5) (a . 3) t) (c) (error "a=%d b=%d" a b)) 13)
eval((funcall baz 13) t)
ielm-eval-input(#("(funcall baz 13)" 0 16 (fontified t)) nil)
ielm-send-input(nil)
ielm-return()
funcall-interactively(ielm-return)
call-interactively(ielm-return nil nil)
command-execute(ielm-return)
ELISP> (car baz)
closure
ELISP> (cdr (assoc 'a (cadr baz)))
3 (#o3, #x3, ?\C-c)
ELISP> (rplacd (assoc 'a (cadr baz)) 42)
42 (#o52, #x2a, ?*)
ELISP> baz
(closure
((b . 5)
(a . 42)
t)
(c)
(error "a=%d b=%d" a b))
- Re: Naming FCRs, (continued)
- Re: Naming FCRs, Jim Porter, 2021/12/26
- Message not available
- Re: Naming FCRs, Jim Porter, 2021/12/28
- Re: Naming FCRs, Phil Sainty, 2021/12/28
- Re: Naming FCRs, Richard Stallman, 2021/12/29
- RE: [External] : Re: Naming FCRs, Drew Adams, 2021/12/29
- Re: Naming FCRs, Stefan Monnier, 2021/12/29
- Re: Naming FCRs, LdBeth, 2021/12/29
- Re: Naming FCRs, Richard Stallman, 2021/12/29
- Re: Naming FCRs, tomas, 2021/12/30
- Re: Naming FCRs,
Tomas Hlavaty <=
- Re: Naming FCRs, Stefan Monnier, 2021/12/30
- Re: Naming FCRs, Tomas Hlavaty, 2021/12/30
- Re: Naming FCRs, Richard Stallman, 2021/12/30