On a related note, can someone post a macro that binds a value to an
identifier without requiring that the identifier be define'd first? I've
often been puzzled by why scheme requires the programmer to define a
variable before assigning to it, in contrast to lisp. Of course, you can
(and generally do) assign a value when you define the variable, but
subsequent assigns must use set! instead of define (unless you want to
redefine the variable each time you use it, which seems inefficient).
I'm looking for something like set! which first checks to see if the
variable has been defined. If not, it defines it and binds the value; if
so, it just binds the value. This is especially useful within loops.
This is also relevant to translators for other scripting languages, since I
know of none that don't allow the user to assign a variable to a new value
with the same syntax as for the initial binding of a variable to a value.
I'd be interested in hearing the philosophy behind the scheme choice. I
have no religious bias on the issue :-)
P.S. Looking at the macros that were posted for the set! that returns a
value, I have to say that the define-syntax macros are exceptionally
elegant and easy to read. I wish this style of macros were used more