[REBOL] Re: Context - code included- 2nd version
From: lmecir:mbox:vol:cz at: 16-Sep-2001 13:48
Hi Romano,
> I've read your new implementation of Contexts. Now it is more near to Core
> Doc. Must re-read it in the next days.
> For now (but you have abandoned Loaded idea):
I accepted Holger's suggestion.
> 1) I prefer this for a pratical reason: it doesn't change the global
context:
> gen-bind: func [
> {Binds WORD to a specified context.}
> word {A value to bind.}
> known-word [word!] {A sample word from the target context.}
> ] [
> first bind to-block mold :word known-word
> ]
As far as I know my definition of GEN-BIND doesn't change the Global
Context. (If your findings are different, post an example, please.)
Moreover, your implementation has got a "hole" :
word: to word! "nonsense:" ; == nonsense:
type? word ; == word!
type? first to block! mold :word ; == set-word!
> 2) My new s-c? This could change the GC but it is very concise. I have
another
> which doen't change the Gc but it is more long. Is this bug Free?
same-context?: func [
{
find out, if the given Words
are bound to the same Context
}
word1 [any-word!]
word2 [word!]
] [
found? any [
all [
undefined? word2
undefined? :word1
]
all [
not special? word2
same? :word1 gen-bind to-word :word1 word2
]
]
]
No, it isn't. It resembles one of my older implementations, but it doesn't
yield the correct result e.g. in this case:
word1: 'word1
word2: use 'word2 ['word2]
> Ciao (my english is bad)
> Romano
Ciao (neither my english is perfect)
Ladislav