Timeline for Any way to access a lexical let variable outside of the let?
Current License: CC BY-SA 4.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 29 at 7:15 | history | edited | NickD | CC BY-SA 4.0 | added 315 characters in body |
| Jan 29 at 7:11 | comment | added | NickD | You are right: @Tobias made that clear in his answer, so I left mine alone. I was basically responding to the last sentence of the OP's question at the time, and I never thought about lexical binding. Edited the answer slightly - thanks! | |
| Jan 29 at 5:51 | comment | added | Zoey Hewll | Nitpick: your statement about let bindings being "local in scope and limited in lifetime" is misleading. let can introduce either a dynamic or lexical binding. Usually, either will when the block ends (so its lifetime is that of the block), but a lexical binding can be captured by a nested lambda, allowing the binding to outlive the block that established it (so that it has indefinite lifetime). That said, I agree with your conclusion in the context of this question. | |
| Mar 31, 2023 at 0:09 | comment | added | phils | I see you've indicated in another comment that advice is inadequate for your purpose, and I'm not trying to argue otherwise; I'm just saying that "an extreme poverty of tools" isn't an accurate description when you have (a) the ability to redefine functions; (b) the ability to advise them in many different ways; and (c) if you really, really, really want to (and you shouldn't), the ability to manipulate code as data. Compared to many languages, this is a veritable wealth of tools. | |
| Mar 31, 2023 at 0:00 | comment | added | phils | Emacs Lisp, like some other lisps, implements a general-purpose advice system (two of them, in fact) which is as good a system of "tweaking" other functions as I've encountered. gnu.org/software/emacs/manual/html_node/elisp/… documents the newer of the two systems. Advising functions is generally a last resort, but the ability is a blessing when you need it. | |
| Mar 30, 2023 at 20:46 | history | edited | NickD | CC BY-SA 4.0 | added 205 characters in body |
| Mar 30, 2023 at 20:27 | comment | added | sextrism | In a lot of programming contexts I might feel the need to tweak one library function, and I find an extreme poverty of tools for that (short of redefining the function and falling behind on updates) in all programming languages I know about. | |
| Mar 30, 2023 at 20:22 | comment | added | sextrism | I should've read the org-element-link-parser definition more carefully, I knew about :end, thought I didn't want it, but didn't realize that applying (skip-chars-backward " \t") on it is equivalent to link-end. In this case I won't need to expose a variable inside a let inside a lexical function, but I'll leave the question up just in wonder if it's possible. | |
| Mar 30, 2023 at 20:14 | history | answered | NickD | CC BY-SA 4.0 |