Word can refer to any context at any point in run-time.
Yes, but only 1 at time, right?
@secret
is still a variable (taken from: http://ruby-doc.org/core-2.4.0/Binding.html ):class Demo
def initialize(n)
@secret = n
end
def get_binding
return binding()
end
end
k1 = Demo.new(99)
b1 = k1.get_binding
k2 = Demo.new(-3)
b2 = k2.get_binding
eval("@secret", b1) #=> 99
eval("@secret", b2) #=> -3
eval("@secret") #=> nil
any-word!
), and context is provided by separate values (object!
or function!
). Binding is a relation between two separate entities, which you can manipulate at run-time (words and functions/objects). Variable, on the other hand, is a way to reference a value, but not a relation between the two values.
@nedzadarek since "variable is a way to reference a value", "variable" (in your interpretation) can be either:
Word is not a variable in any of these cases, it never refers to the value directly, it's always refers to a context provided by some value (either by object on the heap or by function on the call stack).
@ne1uno
did rebol have a bigger problem leaking context?
Currently Rebol 2 and Red are little different in this regard.
use
seems like a solution in search of a problem in red
An interesting way of looking at it. I've long found it a very tidy way of creating micro-contexts. With Rebol 3's tighter control on context, I've found it a useful way of tracking word useāeven within modules.
P: context [
F: [
P1: [
name: "John"
]
P2: [
name: "Mary"
]
]
]
set [list1 list2] compose [
(words-of (Context (P/F)))
(values-of (Context (P/F)))
]
; this works
set [list1] compose [
(words-of (Context (P/F)))
]
; this doesn't work
forall list1 [
probe list1/1
]
forall list2 [
probe list2/1
]
P: context [
F: [
P1: [name: "John"]
P2: [name: "Mary"]
]
]
set [list1 list2] reduce [
words-of context p/f
values-of context p/f
]
forall list1 [probe list1/1]
forall list2 [probe list2/1]
compose
application and you'll probably figure out that it's not what you expected.
compose/only
instead, which composes nested blocks "as-is" (though compose
is superfluous here, as reduce
can do the same job just fine). Moreover, I don't get why you need multiple parenthesis nestings.
@greggirwin
One of the great and terrible things about Redbol langs is their chameleon ability. @nedzadarek, a great many details are hidden under a facade that makes Red quickly accessible to people, but there is the risk that they will see it "as just like X", when it really isn't.
That has been just my problem. The original REBOL core manual did not a good job on letting me forget about variables, pointer and classic OOP.