Re: [racket] About set-car! and set-cdr!

2014-03-05 Thread Daniel Carrera
Thanks! On 6 March 2014 01:00, Alexander McLin wrote: > Daniel, I think it'll be worthwhile to direct your attention to this blog > entry which goes into more details about why mutable pairs were removed in > the first place. > > http://blog.racket-lang.org/2007/11/getting-rid-of-set-car-and-se

Re: [racket] About set-car! and set-cdr!

2014-03-05 Thread Alexander McLin
Daniel, I think it'll be worthwhile to direct your attention to this blog entry which goes into more details about why mutable pairs were removed in the first place. http://blog.racket-lang.org/2007/11/getting-rid-of-set-car-and-set-cdr.html On Wed, Mar 5, 2014 at 4:15 PM, Jens Axel Søgaard wrot

Re: [racket] About set-car! and set-cdr!

2014-03-05 Thread Jens Axel Søgaard
(require compatibility/mlist) (mlist 1 2 3) See http://docs.racket-lang.org/compatibility/mlists.html?q=mlist#%28def._%28%28lib._compatibility%2Fmlist..rkt%29._mlist%29%29 2014-03-05 22:06 GMT+01:00 Daniel Carrera : > > On 5 March 2014 19:54, Matthias Felleisen wrote: >> >> >> Okay, now see mco

Re: [racket] About set-car! and set-cdr!

2014-03-05 Thread Daniel Carrera
On 5 March 2014 19:54, Matthias Felleisen wrote: > > Okay, now see mcons. > Neat... mcons, mcar, mcdr, mpair, set-mcar!, set-mcdr! I notice that there is no mlist. Is there a shortcut similar to '(1 2 3) to quote a list in a way that makes mutable pairs instead of regular pairs? Cheers, Danie

Re: [racket] About set-car! and set-cdr!

2014-03-05 Thread Matthias Felleisen
Okay, now see mcons. On Mar 5, 2014, at 1:53 PM, Daniel Carrera wrote: > I see. > > k is '(42 2 3) while l is '(1 2 3). This is what I expected to happen, but it > is clearly not what was supposed to happen. I just tried the same example > with Chicken, and for Chicken both k and l are equal

Re: [racket] About set-car! and set-cdr!

2014-03-05 Thread Daniel Carrera
I see. k is '(42 2 3) while l is '(1 2 3). This is what I expected to happen, but it is clearly not what was supposed to happen. I just tried the same example with Chicken, and for Chicken both k and l are equal to '(42 2 3). Thanks for the explanation. Cheers, Daniel. On 5 March 2014 19:24, Ma

Re: [racket] About set-car! and set-cdr!

2014-03-05 Thread Daniel Carrera
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. Cheers, Daniel.

Re: [racket] About set-car! and set-cdr!

2014-03-05 Thread Matthias Felleisen
Try (define l (list 1 2 3)) (define k l) Now what does (set-car! k 42) do? What should it do? On Mar 5, 2014, at 1:23 PM, Daniel Carrera wrote: > 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 differen

Re: [racket] About set-car! and set-cdr!

2014-03-05 Thread Matthias Felleisen
No, set! mutates variable bindings while set-car! mutates cons cells (the first slot of a data structure). On Mar 5, 2014, at 1:13 PM, Daniel Carrera wrote: > Hello, > > My understanding is that Racket intentionally does not provide set-car! and > set-cdr! and that this is one of the ways i