0

私はこのシナリオを持っています:再帰的なプロシージャ(または関数)は次のように呼び出されます

{DoSomething Data C}

Cは最終結果を格納する変数であり、関数プロトタイプは次のとおりです。

proc {DoSomething Data N}
     %.. 
     %.. 
     {DoSomething Data M}
     N = 1 + M
end

Nは、最終結果も格納する必要がある変数ですが、プロシージャのローカルスコープにあります。

さて、最初に、プロシージャが呼び出されると、SASは次のようになると言われました。

CとNの間の等価セットに注意してください(両方とも今のところバインドされていません)

次に、すべての再帰が完了した後、SASは

CとNの両方が値(6)にバインドされていることに注意してください

手順を終了した後、SASは

N変数を破棄するためです。そして、それは大丈夫です。

私の質問は、プロシージャの再帰中に何が起こるかということです。C変数は部分値構造1+Mにリンクしていますか?そして次にMが1+M2にリンクするとき?

4

1 に答える 1

1

No, there are no partial structures in Oz, as long as we talk about simple integer arithmetics.

This statement:

N = 1 + M

will block until M is fully determined, i.e. is bound to an integer.

To really understand what is going on, I would have to see the full code. But I assume that there is a base case that returns a concrete value. Once the base case is reached, the recursion will "bubble up", adding 1 to the result of the inner call.

In other words, the binding of C will only change at the end of the outermost procedure call, where M is 5 and C is therefore bound to 6.

于 2012-01-01T16:25:16.030 に答える