Avoiding Function Names Clashes.

My "default-library" has grown to define 464 new symbols, mostly functions. Most of these are generated, so they are not interesting. Nevertheless, there is significant probability that I'll try to use same name twice - especially if I use abbreviations.

That's why I defined version of "set" named set-undefined - if symbol already has value, set-undefined throws an error.
(set 'set-undefined 
(lambda-macro(var-expr val-expr)
(let ((evar-expr (eval var-expr)))
(when (eval evar-expr)
(throw-error (append (char 8)
(char 8)
(char 8)
": "
"(SU " (string var-expr)
" " (string val-expr)
") where "
(string var-expr)
" => "
(string evar-expr)
" => "
(string (eval evar-expr)))))
(set 'toeval (list 'set
(list 'quote evar-expr)
val-expr))
(eval toeval)
nil)))

(set-undefined 'SU set-undefined)
SU is especially useful.

Ops. I didn't syntax-colored this post. OK, we can live with that.

No comments:

Post a Comment