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

[REBOL] Re: Context - ...etc...

From: joel::neely::fedex::com at: 14-Sep-2001 1:53

Hi, Holger, THANK YOU! This is the kind of rationale and operational explanation that some of us have been eagerly desiring for quite some time! I truly believe that, given this kind of concise detail, the REBOL community would gladly rise to the task of writing tutorials and explanations that would present the workings of REBOL in a manner suitable both for the beginning programmer and the newcomer to the language (with other programming experience). I, for one, have given lots of thought (and made public presentations) in the general area of "REBOL for Perl programmers" (or other backgrounds). However, I've been VERY reluctant to commit too much to writing because of the number of subtleties in REBOL's implementation for which I had no authoritative description, and therefore some degree of doubt that my understanding was complete. Having said that... I must add, in defense of everything else that has been written in this thread, that the prior unavailability of clear, authoritative information such as you've just provided has forced many of us (myself included -- recalling the past discussions of "mutability", "self-referentiality", and "model of series" discussions) to try to make up our own models as a basis of explaining and predicting REBOL behavior. It is inevitable -- absent any authoritative responses to the oft- raised questions about such matters -- that our home-brewed models and descriptions will be incomplete, inaccurate, or redundant in some ways. Therefore... Please accept my profound thanks for providing us a glimpse into the world of "The Inner Game of REBOL" (a working title I actually played with and discarded in frustration), and likewise accept my earnest plea for your open and frank responses to REBOL questions to continue. More of this will go a VERY long way to helping us use and promote REBOL more effectively! -jn- Holger Kruse wrote:
> - Words do not "store" values, they ARE values... > > When evaluating a value the result is, usually, another > value... Those values are not stored in words, they are > stored in contexts. > > - Contexts are not word tables, but name-value lookup tables... >
> - to-block! does not bind words into a context. make word! > and to-word bind all words into the global context... > > - The global context expands automatically... > > - Aliases ... are global, not local per context. > > - Scoping: REBOL uses lexical scoping, not dynamic scoping, > but allows words to be rebound during block evaluation... > > - The "bug" you described when combining 'use with functions > and other contexts is not a bug. It is intentional. There > are only four ways how a function can (theoretically) access > its local variables and arguments, in any language: > > - Using a hidden context pointer... > > - By creating a completely new "environment" for each function... > > - By keeping a single function body for all function invocations,.. > > - By keeping a single function body for all function invocations,.. > > - ... the context of the outer function remains intact (indefinite > extent) AND retains its values after the outer function returns > (for non-recursive function invocations), under certain > circumstances. This is an implementation detail you should not > rely on, because it is likely to change in future versions, i.e. > there is a good chance that in the future after a (non-recursive) > function invocation the values of that function's context are > set to unset!. This would break the way your inner function > references the outer function's arguments after the outer > function has returned. >
> This also resolves the drawback you mentioned, i.e. use > > f: func [x] [func [] reduce [x]] > > and the behavior is as expected and compatible with future versions. >
-jn- -- ------------------------------------------------------------ Programming languages: compact, powerful, simple ... Pick any two! joel'dot'neely'at'fedex'dot'com