How to associate a local context block with a global context in Rebol2?

As I understand it, you should be able to bind any block to any context. In particular, you can bind the global context block to the local context:

>> a: context [
    print: does [rebol/words/print "yeah!"]
    f: func[b] [do bind b 'print]
]

>> a/f [print "hello"]
yeah!
== "hello"

So you also need to bind the local context block to the global context? But my attempts were unsuccessful:

>> b: context [
    b: [print "hello"]
    print: does [rebol/words/print "yeah!"]
    f: func[] [do bind b 'system]
]

>> b/b
== [print "hello"]

>> do b/b
yeah!
== "hello"

>> b/f
hello

>> do b/b
hello

I seem to have done this, but:

>> equal? bind? 'system bind? in b 'b
== false

>> same? bind? in b 'f bind? in b 'b
== true

What is my mistake?

+4
source share
2 answers

You link the words in the block assigned b/b, you are not required for the word itself b.

>> equal? bind? 'system bind? in b 'b
== false

, 'system, - , in b 'b ( b ).

, , . , . , , b/b, , b/b, 'b.

:

>> equal? bind? 'system bind? first get in b 'b
== true

, , - , b/b, print, . - , b/f.

+4

, . , , . , b/b ( in b 'b) , . , :

>> equal? bind? 'system bind? b/b/1
== true
+4

Source: https://habr.com/ru/post/1529087/


All Articles