Reusable or Global Variables for Expressions
Having reusable variables is something that would make expressions a lot more DRY, and it would make it a lot easier to work with expressions. This would be useful when you want to reference information that a property can't contain (such as text, arrays, functions or objects).
SOLUTION
Have an "Expression Layer", a new type of layer. Expression layers would have a property where you put in an expression. The special thing about this expression is that you can set global variables which can be referenced in other properties' expressions. Alternatively, instead of an expression layer, there could be an expression property inside nulls.
Here's what you could do in an expression like that:
thisLayer.themeColor = "blue"
Then it could be referenced like this:
comp("example").layer("example").themeColor

-
Max commented
@Micah The huge advantage of global variables is the fact that they are … well … global. Of course I can pickwip a color from another layer, but once you use variables things become quite awkward really fast. Let’s say you pick-whip a color property from „Layer 1" and assign variable „c“ to it. With global expressions I could reference this variable on many layers. If for some reason I want „c“ to not reference the color of „Layer 1“ but „Layer 2“, I would only have to change the the assignment once, on the global expression layer.
Right now I have to go through every layer where I defined „c“ = color from „Layer 1“ and change it to „Layer 2“. -
Micah Haun commented
How is this different from adding expression controls (slider, point control, color control, etc) to a layer or null and referencing that in an expression?
-
Ayub Kokabi commented
Sometime we need to define a global function once somewhere and call it in every expression without redefining or coping it.