文字列をロードすると、デフォルトでユーザー コンテキストに偏ります。
>> f: 3
>> outside: object [
f: 4
getter: does [
print reduce compose [(load "f")]
]
]
>> outside/getter
3
これは、 「単語とその値を lib からユーザー コンテキストにインポート (内部化)」するために使用するLOAD の実装のアーティファクトであることが判明しました。intern
これを回避するには、LOAD を介して潜在的に役に立たないバインドを作成する非効率性を回避し、代わりに TO-WORD を使用してから、オブジェクトを使用しself
て再バインドします。
>> m: 10
>> inside: object [
m: 20
getter: does [
print reduce [(bind to-word "m" self)]
]
]
>> inside/getter
20
ここで私の質問:定義上の「スコープ」が機能
する方法を考えると、このパターンgetter-code
とgetter-text
両方の出力に対して、現在または将来の方法はまったくありません4 20
。
>> f: 0
>> m: 0
>> ctx: context [
f: 4
m: 10
both: object [
m: 20
getter-code: does [print [f m]]
getter-text: does [impossible-print ["f" "m"]]
]
]
たとえば、impossible-print
書き込めないところに根本的に欠けているものがありますか?