Domanda

I have this scenario: a recursive procedure (or function) is called like

{DoSomething Data C}

and C is the variable that should store the final result, the function prototype is

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

and N is the variable that should store the final result too but in the local scope of the procedure.

Now it was told to me that at first, when the procedure is called, the SAS is:

Notice equivalence sets between C and N (both unbound for the moment)

then after all recursions have been completed, the SAS is

notice that both C and N are bound to a value (6)

After exiting the procedure the SAS is left with

because you destroy the N variable. And that's fine.

My question is: what happens during the procedure recursions? Does the C variable link to a partial value structure 1 + M ? And then next time M links to 1 + M2 ?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top