[plt-scheme] boxes?

From: John Clements (clements at brinckerhoff.org)
Date: Tue Jan 23 22:49:57 EST 2007

On Jan 23, 2007, at 7:17 PM, Gregory Woodhouse wrote:

> On Jan 23, 2007, at 5:42 PM, Carl Eastlund wrote:
>> The problem here is not that numbers and lists work differently, but
>> that lists and *variables* work differently.  The (set! ...) form
>> works on variables, not values; the set-car! form works on  
>> values.  It
>> would be possible to implement integers that had a "set-integer!"
>> procedure, so you could modify an integer as it was passed around,  
>> but
>> that's not the same as set!.
> Fair enough, but my point (rather a trivial one, perhaps) was that  
> the similarities in syntax can be confusing.
> My understanding (right or wrong) is that (set! x 4) changes the  
> binding of the nearest enclosing x to 4. At least that's how I  
> implemented it in my evaluator.

No, you're exactly right: set! changes a _binding_.

Furthermore, you're also exactly right in saying that the  
similarities in syntax can be confusing.  Don't be suckered, though:  
set-car! changes a _value_, not a binding.

I think you will find many sympathetic ears in suggesting that set!  
and set-car! are unfortunately close.

One final illustration of the difference: set-car! evaluates both of  
its arguments before doing its work; that is, it's a regular  
function.  set!, because of the magic that it works on bindings, is not.

John Clements

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20070123/da6a0381/attachment.p7s>

Posted on the users mailing list.