This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Assignment to syntactic keywords in guile



I actually think R5RS articulates a pretty clear model for how this
works:

Every valid usage of an identifier has lexically apparent binding.  It
might be either a syntactic binding or a variable binding.

Identifiers can be used as either keywords or variables.  In some
contexts, it is clear from the grammar which is meant.  For example,
`x' in `(+ x 3)' must be a variable reference.  In other contexts, you
need to know identifier's binding to decide what form of expression
you have: in `(x 3)', you need to know the binding of `x' to tell
whether this is a <procedure call> or something else.


Under this model, an expression like (set! x set!) is incorrect
because the last use of `set!' takes place in a context which requires
it to be a variable reference, but set! has no binding in scope.  A
Scheme system should treat this as a reference to an unbound variable.
Guile happens to allow it, due to quirks of its implementation.

Under this model, an expression like (let ((set! +)) (set! x 4)) is
valid, and returns x + 4.  The let introduces a new binding for set!,
and in the subexpression `(set! x 4)', the fact that set! is bound to
a variable means we have a <procedure call>, not an <assignment>.


Argh.  I don't have time to write this all out clearly.  But I think
if you read through R5RS, you'll find it's pretty clear about how this
is all supposed to work.  But like so many things in R5RS, you have to
pull together little comments scattered throughout the document to see
the big picture.  It's a damned good thing it's only fifty pages long.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]