ClearAll[f, b]
SetAttributes[f, HoldRest]
f[x : (True | False), true_, false_] :=
With[{tHash = Hash[true], fHash = Hash[false]},
f[x, _?(Hash[#] == tHash &), _?(Hash[#] == fHash &)] = If[x,
Print["true"]; true,
Print["false"]; false
]
]
With[{true = RandomInteger[100, 10], false = RandomInteger[100, 10]},
Dynamic@f[b, true, false]]
Checkbox@Dynamic@b