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

[REBOL] Re: Scope? Any advice would be appreciated.

From: lmecir:mbox:vol:cz at: 30-Jan-2001 8:48

Hi Victor, I would like to answer your questions.
> Although I can "see" that the datatype determines the functionality of the > assignment operator,
The above is incorrect. Compare the samples: s1: function [] [x] [ x: 1 print either x = 1 ["Expected!"] ["Unexpected!"] x: 2 ] s1 ; Expected! ; == 2 s2: function [] [x] [ x: [1] print either x = [1] ["Expected!"] ["Unexpected!"] x: [2] ] s1 ; Expected! ; == [2]
> its not documented in the Rebol guide under "Setting > Words" and the behavior is not consistent with immutables. >
The assignment operator behaviour is consistent with immutables/immutables (see above). The only thing, that is inconsistent with mutables as opposed to immutables is the fact, that if you change the mutables contained in your code, you are causing the code to become self modifying, which is surely a dangerous practice, especially if you don't know what you are doing.
> On the surface, the first pass through the routine, b: [ 0 0 0 ] does the > same thing as b: 0. But on subsequent runs the behaviors part paths and > cause confusion and unexpected behavior for those of us who do not > understand the underlying logic of Rebol. But, then again, why should I > need to understand the underlying logic of Rebol? If the basic
> manual doesn't explain this, then how is anyone to know it? How many
> undocumented design decisions are there that impact basic operational > usage? > > Also, I still don't see the value here - what benefit is secured by making > these two different? Why do I have to use "copy" to accomplish with > mutables the same thing that is accomplished without "copy" for
immutables? Even with copy you still cannot accomplish exactly the same with mutables as with immutables. Immutables are really protected against change (no way to change them at all, which protects a programmer against a lot of errors). To have a better symmetry, the introduction of immutable blocks as a new dataty pe might help (especially the beginners may be less confused)?