How do I make this work intuitively?
f[x_] := x^2 /; a>0 f[2] /. a->1
I want the answer to be 4 because 1>0 is True, but it does not work. It works if I make a_ an argument of f, but I don't want to for various reasons.
Here is idiomatically correct version of your code that works:
f[x_] := x^2 /; a > 0 Block[{a = 1}, f[2]]
This works, but it is awkward:
g[x,a]:=x^2 /; a>0
h
h[2]/.a->1
4
Note that that was one of my suggestions.
Why so complicated? How about simply:
f[x_] := If[a > 0, x^2, "whatever"]
this works exactly as intended:
a=.; f[2] /. a->1
Yours Henrik
Block is indeed the correct solution.