Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: On mutability and sameness

From: joel:neely:fedex at: 17-Jun-2001 16:32

Hi, Ken, Ken Anthony wrote:
> Joel, I'm being dense again. > > When you say the integers are immutable in Rebol (implying > they may be mutable in other languages?) >
Believe it or not, they used to be... ;-) Questions 16-18 of "The Hacker Purity Test", found at http://www.armory.com/tests/hacker.html ask 16. 0x00F Ever change the value of 4? 17. 0x010 ... Unintentionally? 18. 0x011 ... In a language other than Fortran? but that's a story for a long summer's evening in the mountains with a campfire and some marshmallows.
> You referred to mutating verses replacing. > > > a: 42 > > a: a + 1 ;=43 > > Could I not see this as an example of mutating the rightmost > bit? >
I don't think it's useful to do so. Suppose there had been more intervening steps:
>> a: 42 == 42 >> b: a + 1 == 43 >> a: b == 43
or
>> a: 42 == 42 >> b: reduce [a + 1] == [43] >> a: first b == 43
or even
>> a: 42 == 42 >> b: to-char a // 10 + 49 == #"3" >> c: to-char (to-integer a / 10) + 48 == #"4" >> d: rejoin [c b] == "43" >> a: to-integer d == 43
Would that same idea still hold? At what point does "the 42" get altered? I believe it's simpler to understand that a: ... some expression ... sets A to whatever the expression evaluates to, and it's only coincidental that the expressions we've been talking about happen to use the former value of A. -jn- ------------------------------------------------------------ Programming languages: compact, powerful, simple ... Pick any two! joel'dot'neely'at'fedex'dot'com