I have a problem I'm trying hard to find a solution for, although I don't know if a solution exists.
The following rules produce the result e[2].f[]
x_G . f[] ^:= x
G[x_, ___, y_] := y[x]
G[2, e] . f[]
Would it be possible to get e[2] instead ?
I'm not sure it's possible as x in the left hand side of the definition of f is copied to the right hand side after having been evaluated. A solution would be to put a temporary HoldFirst attribute to Dot but this has undesirable side effects on the language.
Basically the usage I'm looking for is that an expression of the form G[x_, ____ , y_ ] is transformed to y[x], but not if it's part of an expresion of the form G[____].f[___], where in this case an UpValue should first be used, but the DownValues transformation to y[x] can happen in the rhs of f.
Would analyzing the stack help maybe? I tried that without success.