I am reading the Common Lisp Hyperspec and am struggling to understand the concept behind the Special declaration.
Namely, what are the special variables and why would we want them? I gathered that somehow we can change which scope the variable belongs to in the eyes of the compiler by using the special declaration, but the details elude me.
Could someone explain and perhaps give some examples?
Special variables are dynamically bound. That means:
Notice that lexical rules of scoping does not apply. Rather than that it behaves like the very first Lisp. If global variables would not been special the result would be
30
. You can introduce hard to find bugs by accidentally declaring a variable special. To avoid this we use*earmuffs*
.