<div dir="ltr">But isn't the final effect the same? The pair may be immutable, but I can make a new pair and bind it to the old variable. The main difference that I can see is that what I wrote is a macro, while I believe set-car! is supposed to be a function. That could potentially break code.<div>
<br></div><div>Cheers,</div><div>Daniel.<br><div class="gmail_extra"><br><br><div class="gmail_quote">On 5 March 2014 19:18, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
No, set! mutates variable bindings while set-car! mutates cons cells (the first slot of a data structure).<br>
<br>
<br>
On Mar 5, 2014, at 1:13 PM, Daniel Carrera wrote:<br>
<br>
> Hello,<br>
><br>
> My understanding is that Racket intentionally does not provide set-car! and set-cdr! and that this is one of the ways in which Racket is not fully compatible with Scheme.<br>
><br>
> Am I right to think that it is trivially easy to add these features to Racket? Specifically, I'm thinking of:<br>
><br>
><br>
> (define-syntax set-car!<br>
> (syntax-rules ()<br>
> ((_ l new_car) (set! l (cons new_car (cdr l))))))<br>
><br>
> (define-syntax set-cdr!<br>
> (syntax-rules ()<br>
> ((_ l new_cdr) (set! l (cons (car l) new_cdr)))))<br>
><br>
><br>
> Or did I miss something?<br>
><br>
> Cheers,<br>
> Daniel.<br>
<span class="HOEnZb"><font color="#888888">> --<br>
> When an engineer says that something can't be done, it's a code phrase that means it's not fun to do.<br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>When an engineer says that something can't be done, it's a code phrase that means it's not fun to do.<br>
</div></div></div>