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

[REBOL] Re: WYSIWYG programming (was: Block Creation)

From: holger:rebol at: 30-Oct-2000 9:32

On Wed, Oct 25, 2000 at 03:05:21AM +0200, Ladislav Mecir wrote:
> Another example showing what is wrong with the Self Modifying Code: > > a: [append a [+ 1] 1]
The above expression modifies a block while it is being evaluated. AFAICT at this time the result of such an operation should be considered "undefined" and implementation-dependent . In other words: don't do that ! I don't think the behavior can be called a bug as long as no specs have been defined for how the language should behave in this case. Most languages have expressions which are well-formed within the language, yet have unspecified semantics. An example is something like a: (*p++)+(*p++) in C. Here it is undefined whether the second access to "p" occurs before or after incrementing it for the first time (assuming I remember the C specs correctly...) A "legal" way to rewrite the above REBOL expression would, e.g., be: a: [append last a [+ 1] do [1]] This way the main block does not get changed during evaluation. Only the block referenced from the main block (the one initialized to be [1]) gets changed. That is completely legal. I hope you can see now why I dislike the term "self-modifying code". There is conceptually a huge difference between the first and second example, and the term "self-modifying code" tries to be a catch-all phrase that encompasses (and discourages) within the same category both legal (and potentially useful) and illegal practices. -- Holger Kruse [holger--rebol--com]