Romano, I understand how and what happens when words which are local to functions are not defined, they are defined to the 'none value when REBOL evalautes the function, however my contention is that REBOL should not do this and leave all local words unset if they are not defined, just as would happen in a 'use context or in the global context system/words, or indeed an object context although this would involve first defining the new word in the object! context then explicitly unsetting it with the 'unset function.
My preference would be all words are defined as local to their context, including words defined in objects, functions and use contexts. All undefined words are intitialised to the 'unset value and are testable with the value? or unset? get/any 'word functions. This seems the most logical, simple, straightforward and consistent solution to me, however it's not REBOL behaviour so we just have to make do with the quirkiness that is current REBOL behaviour / design. Makes it much harder for everybody however to have to learn and remeber all these special cases and exceptions, don't you agree. cheers, Mark Dickson In a message dated Thu, 6 Dec 2001 10:44:00 AM Eastern Standard Time, "Romano Paolo Tenca" <[EMAIL PROTECTED]> writes: > Hi Mark > > > WHY is setting words in functions to 'none by default useful? > > When you create the function, all the words (args, refinements, args of > refinements) are binded at a new hidden context and the starting value of > words in context is the unset value. > When you execute the function, all the args and refinements and args of > refinements are set to none if they are not used in the function call. It is > more easy to test a none value of an unset value (none = false for > if/either/while/until...). > The so called "locals words" of a function are only arguments of the > refinement 'local, so they are set to none like any other argument not used in > the function call. > > > Why is the ability to use apparently unset words a desirable feature? > > Does this not confuse the language in that words cannot be used until after > they have been defined? > > An unset word is a word with the value unset. It is like any other value and > any other word. If you use it where a function ask a value, Rebol triggers an > error. But Rebol triggers the same error if you pass an argument of type > integer! where a function ask for a value of type unset: > > >> x: func [a [unset!]][value? 'a] > >> do [x ()] > == false > >> do [x 1] > ** Script Error: x expected a argument of type: unset > ** Near: x 1 > > BTW, I think that the name of function value? is confusing. It should be > something like: not-unset-value? > And also unset is confusing, because you can set a word at the unset value: > > >> set/any 'a () > >> value? 'a > == false > > my conclusion: unset <> no value > A true word without value is a word out of context which trigger the error: > > "is not defined in this context" > > > Now we have another "exception" case for words in functions. > > What makes words in functions different from global words or words in > objects or words in a use context? > > That they are also arguments. Functions are not contexts, they only use a > context to mask the global context from the value of their arguments. > > --- > Ciao > Romano > > > > -- > To unsubscribe from this list, please send an email to > [EMAIL PROTECTED] with "unsubscribe" in the > subject, without the quotes. -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.