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

[REBOL] Re: Fun with literal blocks!

From: joel:neely:fedex at: 29-Oct-2000 14:01

Hi, Ladislav, [rebol-bounce--rebol--com] wrote:
> Hi Joel, > > thank you for choosing the Monsters subject. I would like to > present a somewhat surprising/questionable point of view. >
Debatable, perhaps, but an interesting analysis! (And surprises can be good...)
> 1) A safe statement: the Monsters are undocumented. >
> 2) A questionable statement: the Monsters are *undocumentable*. >
In theory, I might argue with you; in practice -- given the current state of things -- I'd agree that the only adequage model would be the actual source code of the interpreter (as you stated further on).
> I know that it is wrong, if I don't add an explanation, > what that means. Let's go: > > Let me define the Monsters first. > > a) I call a Rebol value a Self Modifying (Rebol Code), if its > evaluation (with a help of Do e.g.) causes its change (to be > precise, I should define what is a Change, but let's leave that > for a future discussion). (This definition differs from a "usual" > definition of a Self Modifying Code!) > b) I call a Rebol value a WYSIWYG (Rebol Code), if its evaluation > (using Do e.g.) doesn't cause an evaluation of a Self Modifying > Rebol Code. > c) There are some Rebol values, like functions/natives If, Either, > For, While, Make, ..., for whose the latter depends on the > argument(s) they receive or on some other unknowns. Such values I > call (relatively) WYSIWYG. >
I understood your point (c) to cover such cases as: twiddle: func ['a [word!]] [ append second get a true ]
>> so-called-data: [[1 2 3] ["a" "b" "c"]]
== [[1 2 3] ["a" "b" "c"]]
>> twiddle so-called-data
== ["a" "b" "c" true]
>> so-called-data
== [[1 2 3] ["a" "b" "c" true]] given that someone could always do
>> second get 'twiddle
== [ append second get a true ]
>> twiddle twiddle
== [ append second get a true true ]
>> twiddle so-called-data
== true
>> so-called-data
== [[1 2 3] ["a" "b" "c" true true]] So, I take your point (a) to mean if its evaluation NECESSARILY causes its change ----------- Did I interpret correctly?
> d) Any Rebol Value, that is not (at least relatively) WYSIWYG > I call non-WYSIWYG. > > I would call a Monster any non-WYSIWYG Rebol Value. > Now back to the questionable statement. I think, that: > > i) The behaviour of Monsters is irregular and heavily > implementation-dependent (see the example Monster below, or > any other Monster I supplied in the WYSIWYG programming thread). >
I agree with your general statement, although it would be possible to specify high-level (e.g. non-implementation-dependent) semantics for some cases. There would probably always be some monstors which would slip through the specificational net, no matter how tightly it was woven...
> ii) Nobody can list all Monsters. > iii) The one thing that could describe the behaviour of all > Monsters is the interpreter source code. > > In the above sense are the Monsters undocumentable, which means, > that their evalualuation shall be avoided as much as possible. >
I think we agree on goal, but I think your "guard rail" is just a bit more conservative than mine. I see a distinction between Monsters such as
>> a: [append a [+ 1] 1]
== [append a [+ 1] 1] and (to invent a bit of terminology) Safely Self-Referential Code such as count: func [/reset val [integer!] /local state] [ state: [0] either reset [ change state val ][ state/1: 1 + state/1 ] first state ]
>> count == 1 >> count == 2 >> count == 3 >> count == 4 >> count == 5 >> count/reset 0 == 0 >> count == 1 >> count == 2
I think it is possible to specify the semantics of a vNL such that one can write Safely Self-Referential Code without too much risk. Of course, I think we're in agreement that such code will always remain mysterious to those who are not yet familiar with REBOL's use of definitional scope and the way in which literal blocks are handled. Whether that level of mystery is unacceptable or not is (to me) more of a matter of opinion than the belief (which I think we share) that general-purpose industrial-strength Monsters should not be allowed to roam the streets, but should be kept in biohazard- equipped zoos. -jn-