Question

In Rebol2, if the global context is system/words, why do I get this result?

>> X: 0
== 0
>> same? system/words bound? 'X 
== false

What is the context in this case? Or is there a problem with using same? on the global context? (I tried repeating the second command in case it changed the context)

Was it helpful?

Solution

I consider this a kind of interpreter quirk. You would not encounter it in Rebol 3. The fact is that the result (results) of bound? differ in Rebol 2 from "normal objects/contexts" by some "type bits". This difference causes the unexpected result of same?. You obtain an expected result e.g. as follows:

same? bound? 'X bound? 'system

By the way, this may be a good test to add to the test suite, if not already present. (in Rebol3 there is no global context, so you may need to use an object for the test to be applicable both to Rebol2 and to Rebol3). The test may look e.g. as follows:

o: make object! [a: none]
same? o bound? in o 'a

As noted above, this test fails in Rebol 2, while it passes in Rebol 3.

As opposed to the above test, this test succeeds in both Rebol 2 and Rebol 3:

o: make object! [a: none]
same? bound? first bind [a] o bound? first bind [self] o
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top