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

[REBOL] Re: Context - code included- 2nd version

From: lmecir:mbox:vol:cz at: 9-Sep-2001 0:08

Hi Romano, thanks again for revealing my bugs, I tried to correct them. The text really needed correction. some comments:
> rebol[ > Title: "Analyze a word" > Date: 30/7/2001 > File: %myword.r > Email: [rotenca--libero--it] > Author: "Romano Paolo Tenca" > Version: 1.0.0 > Category: [text util 3] > Purpose: { > find the type of a Rebol word > Visualize-Context redefined > many functions are a modified version of the > originals of Ladislav Mecir > to reflect the very special words > } > ] > > binded?: func [ > {determines, if a Word is defined in any context} > word [any-word!] > ] [ > not error? try [error? get/any :word] > ]
The above is exactly the opposite of what I want to call a Special Word.
> loaded?: func [ > {determines, if a Word is defined in system-words} > word [any-word!] > ] [ > found? find first system/words word > ]
This notion is your invention and it surely deserves our attention! The fact is, that one Rebol Context (as you have proven) can consist of Loaded as well as Not Loaded Words (except for the Global Context, which cannot contain Not Loaded Words, of course...). The implementation cannot really handle ANY-WORD! values.
> vspecial?: func [ > {determines, if a Word is a Very Special Word} > word [any-word!] > ] [ > found? all [ > not binded? word > not loaded? word > ] > ]
The notion of Very Special Word isn't as useful as the notion of a Loaded Word, because it is only a subcollection of the Special Context I tried to define. It is not a Context.
> special?: func [ > {determines, if a Word is a Special Word} > word [any-word!] > ] [ > found? all [ > not binded? word > loaded? word > ] > ]
This notion is again less useful than the notion of Special Word I am using, which "defines" a Context while this notion can "define" only a subcollection of a Context.
> global?: func [ > {find out, if the given Word is a Global Word} > word [any-word!] > ] [ > found? all [ > loaded? word > same? word bind word 'system > ] > ]
This implementation cannot really handle ANY-WORD! datatype values.
> local?: func [ > {find out, if the given Word is a Local Word} > word [any-word!] > ] [ > found? all [ > binded? word > not global? word > ] > ]
This notion is less useful than the notion of Local Words I prefer, because from two Words of the same Context the first one may be "local" while second non-local .
> local-unloaded?: func [ > {find out, if the given Word is a Local Word not loaded in
system/words}
> word [any-word!] > ] [ > found? all [ > binded? word > not loaded? word > ] > ] > in-object?: func [ > {find out, if the given Word is defined in a object-context} > word [any-word!] > /local self > ] [ > found? all [ > binded? word > not same? 'self bind 'self word > equal? object! type? get/any bind 'self word > ] > ]
the last function is incorrect (and incorrectible, IMO), e.g.: o: make object! [] o/self: 11 in-object? in o 'self ; == false
> in-use?: func [ > {find out, if the given Word is Local to a func or use block} > word [any-word!] > ] [ > found? all [ > local? word > not in-object? word > ] > ]
Incorrectible, I am afraid. ...snip... Cheers and thanks again. Ladislav