Ramarren wrote:makia wrote:ahh, i expiremented a little .... and got it ...
defparameter establish dynamic variable so "a" in (defun test (a) ...) is dynamic not lexical (that's is what confused me, i thought "a" is lexical inside the function)
As far as I know, there is no way to un-special (ie. turn dynamic variable into lexical one) a symbol, locally or otherwise. This is I believe considered a flaw in the language, but it doesn't really come up that often.
If you use the *special* convention, this won't be a problem. That's why I cringed (without even really realizing why, at the time) when makia said "nevermind the convention" and then smiled at "dynamic binding of a is 0". It's remarkably easy even for experienced Lispers to make that mistake, which is
why that convention exists: to remind you that variable *so-and-so* is special.
This flaw is really hard to remedy, given CL's optional type declarations. If we had required type decs, you'd be required to redeclare it as special every time you bound it. But then we'd have required type decs, and, you know, yuck. Even then it could be confusing -- it's awfully easy to forget what C variables are global, for example. In C, many people add some kind of prefix to globals. That's all the *'s are, really.
"Special" variables are one of the few (only?) times in CL that a
variable has a type (or, at least, a property), as opposed to only the value it's bound to having a type.