Let's say I have:
foo: object [bar: 10]
print foo/bar ;-- output 10
Is there some xxx for saying:
foo: object [bar: 10]
xxx foo [
print bar ;-- output 10
]
Binding will work, but is ugly (puts object reference after the block) and you have to call DO:
foo: object [bar: 10]
do bind [
print bar ;-- output 10
] foo
(It also mutates the block parameter by default...which is probably not a good general property for the sought-after xxx.)
USE would seem like a good word for xxx, but it is taken for something else already: it lets you declare words inside a local context while leaving the previous definitions of that word alone:
foo: object [bar: 10]
use [foo] [
foo: object [bar: 20]
print foo/bar ;-- prints 20
]
print foo/bar ;-- prints 10
Does something already do what I want in the box, or does one have to write it? WITH might be a good name, from other languages with a parallel kind of feature.
One option would be to make it an extension of use...perhaps what it did if you gave it a GET-WORD! in the list.