Skip to main content
added 45 characters in body
Source Link
Rojo
  • 42.8k
  • 7
  • 98
  • 190

Imagine the expressions as trees, and the evaluation procedure as a treesuccession of trees, and in each transformation, draw a sign pointing at the new sub-tree, with the symbol responsible written on it. If you ever have to transform that same treesubtree again, the previous sign is lost. When it's time for Return to evaluate, you go up the tree and see the signs in the path to the top. Those are the ones you can use.

Imagine the evaluation procedure as a tree, and in each transformation, draw a sign pointing at the new sub-tree, with the symbol responsible written on it. If you ever have to transform that same tree again, the previous sign is lost. When it's time for Return to evaluate, you go up the tree and see the signs in the path to the top. Those are the ones you can use.

Imagine the expressions as trees, and the evaluation procedure as a succession of trees, and in each transformation, draw a sign pointing at the new sub-tree, with the symbol responsible written on it. If you ever have to transform that same subtree again, the previous sign is lost. When it's time for Return to evaluate, you go up the tree and see the signs in the path to the top. Those are the ones you can use.

added 20 characters in body
Source Link
Rojo
  • 42.8k
  • 7
  • 98
  • 190

The symbols allowed in Return are those which are responsible for a transformation in the partial evaluation of the expression so far. Of course, I'm referring only to the evaluation of the branch that includes the Return. There's a subtlety but I'll mention it later

f[Return[2,g], g] is turned into {Return[2, g]} BECAUSE OF g. Now, Return is evaluated (at a lower level) and that's the way the cookie crumbles

Summary

Imagine the evaluation procedure as a tree, and in each transformation, draw a sign pointing at the new sub-tree, with the symbol responsible written on it. If you ever have to transform that same tree again, the previous sign is lost. When it's time for Return to evaluate, you go up the tree and see the signs in the path to the top. Those are the ones you can use.

The symbols allowed in Return are those which are responsible for a transformation in the partial evaluation of the expression so far. There's a subtlety but I'll mention it later

f[Return[2,g], g] is turned into {Return[2, g]} BECAUSE OF g. Now, Return is evaluated (at a lower level) and that's the way the cookie crumbles

The symbols allowed in Return are those which are responsible for a transformation in the partial evaluation of the expression so far. Of course, I'm referring only to the evaluation of the branch that includes the Return. There's a subtlety but I'll mention it later

f[Return[2,g], g] is turned into {Return[2, g]} BECAUSE OF g. Now, Return is evaluated (at a lower level) and that's the way the cookie crumbles

Summary

Imagine the evaluation procedure as a tree, and in each transformation, draw a sign pointing at the new sub-tree, with the symbol responsible written on it. If you ever have to transform that same tree again, the previous sign is lost. When it's time for Return to evaluate, you go up the tree and see the signs in the path to the top. Those are the ones you can use.

added 20 characters in body
Source Link
Rojo
  • 42.8k
  • 7
  • 98
  • 190

Belisarius@belisarius on the comments:

ExtraBonus example:

f[Return[2,g], g] is turned into {Return[2, g]} BECAUSE OF g. Now, Return is evaluated (at a lower level) and that's the way the cookie crumbles

Belisarius on the comments:

Extra example:

f[Return[2,g], g] is turned into {Return[2, g]} BECAUSE OF g. Now, Return is evaluated and that's the way the cookie crumbles

@belisarius on the comments:

Bonus example:

f[Return[2,g], g] is turned into {Return[2, g]} BECAUSE OF g. Now, Return is evaluated (at a lower level) and that's the way the cookie crumbles

Source Link
Rojo
  • 42.8k
  • 7
  • 98
  • 190
Loading