[REBOL] Re: Context - code included- 2nd version
From: lmecir:mbox:vol:cz at: 10-Sep-2001 23:11
Hi,
> > > 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
>
> You are right, it can fail also if you globally define:
>
> self: system/words
>
> or
>
> o: context [self: system/words]
>
> I have tried to correct the last 2 incorrect behaviour in another version.
I
> find
> it useful for visualize-context: it can reveal the object-local-unloaded
words
> that your implementation do not find at all. If the function fails,
> visualize-context can default to the old scheme: scanning system words.
> When this function return true, it is true, when false, it is undefined.
>
Now I know what you were after. The problem is, that the function fails in
the case:
word: use 'self [self: make object! [] 'self]
in-object? word
The correction might be:
in-regular-object?: function [
{finds out, if the given Word is in a regular object}
word [word!]
] [self bound-self] [
found? all [
not special? word
not same? 'self bound-self: bind 'self word
object? get/any bound-self
same? bound-self in get/any bound-self 'self
]
]