This page describes the render order, but the gist is that layers are rendered from bottom to top (referring to their order in the Timeline panel). Effects within layers are rendered from top to bottom.
Say, if every layer and effect had expressions, what would be the order of their execution?
All at once. Unless there is a specific order dictated inside the expression by ordering and chaining variables, the actual order of elements is not really relevant to an expression. It's in its nature of being sandboxed and not caring for the world outside until you tell it to. Whatever issues you have are in the code.
Mylenium, it does. It's difficult to explain, so let me attach a test project. What I was trying to achieve there are two parallel layers (planes) in 3D space and another layer connecting them:
Diagram (top view):
The idea is that once the [front] or [back] layer is moved the [connect] layer should follow. I implement this by tying the Position, and Y Rotation of the [connect] layer with expressions to the other two layers. Each of three layers also has the Beam effect applied, and the Starting Point of the beam in the[connect] layer is also tied in with expressions to the [front] and [back] layers. Take a look at the project for exact expressions -- they are all in the [connect] layer.
While in AE, select the [front] layer, switch to the Selection Tool and start moving that layer around. The connecting layer should follow. Now click on the [back] layer and again with the Selection Tool try to move it around. For some weird reason the connecting layer gets all screwed up. But, while it is messed up switch back to the [back] layer and move it. The connecting layer will fix itself up.
So, how can you explain this behavior?
Well, then you asked the wrong question. Naturally of course effects inherit the transform properties of the parent layer, but the expression itself will evaluate per frame, regardless where it is. In your example it really boils down to you combining two unrelated transform spaces in the first place - since you make no provision in the code to enforce evaluation of the layer position, there is no way it possibly would. It only kicks in when you evaluate the effect because this causes the upstream graph also to evaluate...
OK, Mylenium. I appreciate your analysis. But how do I fix it?
Can't look at your project right now but if you have layer 1 linked to layer 2 by an expression and you move layer 2 layer 1 won't follow. If you write an expression with layer 1 tied to layer 2 and layer 2 tied to layer 1 then you get a circular reference and neither will work as expected.
value + thisComp.layer("Layer 1").position
applied to Layer 2's Position property will make layer 2 follow layer 1 around.
But if you apply:
value + thisComp.layer("Layer 2").position
to Layer 1's Position property things start to get weird because of the circular reference.
Your observation that moving the back layer around gets fouled up until you move the front layer makes perfect sense to me because the back layer is driven by layer 1 but you can't, or at least I can't figure out a way, that you could have the front layer drive the back layer and the back layer drive the front layer without a circular reference that would foul the whole thing up.
The only solution that I can see would be to drive both layers with a Null and animate that.
Thanks, Rick. I'll try to use Null objects for that.