Hacker News new | past | comments | ask | show | jobs | submit login

You mean dynamic scoping and lexical scoping. Dynamic binding is something different; a dynamically-bound subroutine call may call different functions depending on runtime state, for example because it's indirected through a function pointer, for example in the class vtable of a method call receiver.

I agree that it's useful to be able to locally override variables like deactivate-mark and case-fold-search. (This kind of thing makes tail-call elimination more difficult: any dynamically scoped variables must be restored when the "tail-called" function returns.) But there are some other such things in Emacs that can be similarly locally overridden and then restored, but aren't variables: (current-buffer), (point), and (mark), for example, which can be restored with (save-excursion ...). And it's common to have such locally-override-and-restore facilities without using linguistic dynamic scoping for it; PostScript has gsave/grestore, for example, which were copied by Win32 GDI SaveDC and RestoreDC, but that doesn't give C dynamic scoping.

I don't think SaveDC and RestoreDC are known to give rise to problems when "writing a prgoram for other end users that multiple people are working on".

I agree that elisp will never remove dynamically-scoped variables; it would break compatibility with all existing code. Even Common Lisp has "special variables" that behave this way.




I mean, yes, you're not wrong, but the terms within Emacs itself for these features are dynamic/local "binding":

https://www.gnu.org/software/emacs/manual/html_node/elisp/Dy...

https://www.gnu.org/software/emacs/manual/html_node/elisp/Le...


Thank you for the correction; I did not know that. I can complain about the elisp maintainers using an established term in this confusing way†, but I shouldn't have claimed that your use of it was wrong; if you're discussing a particular program, it's better to use the canonical terminology used when talking about that program, even if it conflicts with usages in other contexts.

______

† Older versions of the Emacs Lisp reference manual mostly did not do this, except for one occurrence of "dynamic binding" in the "implementation of dynamic scoping" section.


Dynamic scoping relies on a form of dynamic binding: namely the dynamic binding of a symbol to its current value.


That's outside the standard meaning of Alan Kay's term "dynamic binding," which originates in a different meaning of "binding", namely, "linking object files (into an executable or other form of memory image)". The Mesa linker, for example, was called the "binder". These conflicting meanings of "binding" make for a good pun or joke, but I think there are people trying to read this discussion in all seriousness to understand the linguistic issues, and the pun could confuse them.

It happens that in ordinary Lisps†, the function called by invoking a symbol does depend on the run-time value of a symbol (its function binding in a Lisp-2), and that's the sense in which an ordinary Scheme or (non-generic) Common Lisp function call can be said to be "dynamically bound", but that isn't the case in general. So even in that sense it doesn't correspond to the static/dynamic scoping distinction that they seem to be trying to discuss.

______

† I think this may be one of the points where Lush is atypical; I think its interpreter supports runtime rebinding of the function bindings of symbols, but its compiler doesn't. I'm not sure, though. I may not have used Lush this millennium.


The Lisp term "dynamic" means "stack-like LIFO discipline". "Dynamic scope" is a shorthand that refers to "indefinite scope with dynamic extent", where "dynamic extent" refers to the bindings being tied to stack-like frames, such that they are torn down then constructs terminate.

When we "declare dynamic-extent" an object, the compiler may stack-allocate it.

The C language redefined "dynamic" from "stack" to "heap". If you look into the BCPL manual (one predecessor language that inspired Ken Thompson's B), it uses "dynamic extent" to refer to the stack, which C renamed to "automatic storage":

"[T]he extent of a dynamic data item starts when its declaration is executed and continues until execution leaves the scope of the declaration." (1967 BCPL Manual, 7.2)


I agree. Thank you.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: