Condition usage clarification
I think that the meaning of this sentence is stupidly verbatim: the author simply notes the (almost obvious) fact that this construct allows sharing the localized by Module
variables between the Condition
and the rhs
(which resides inside of the Module
). In contrast, if we move the Condition
outside of the Module
, we won't have the localized variables shared between the rhs
and the Condition
:
f[x_] := Module[{u}, u] /; EvenQ[u]
f[2]
f[2]
Probably this shouldn't be in the Details section: this statement is too obvious to reside there, it doesn't add something meaningful. But from the other side, there are some non-obvious under-documented "smart" rules on how different scoping constricts interact with each other: may be the author simply stresses that this obvious behavior is by design and we may trust it without risk...
I never understood what that line in the documentation meant until I saw use of it in answers on Stack Overflow, i.e. Partial evaluation in Mathematica. As such I am in the camp that feels this documentation could be written more explicitly for a user who is not already familiar with its use.
I propose something along these lines:
For
With
,Block
, andModule
there exists a special constructlhs := With[{vars}, body /; test]
. In this specific instance theCondition
applies to the entire definition uponlhs
as if it werelhs := rhs /; test
but in whichtest
may depend on the localization and evaluation ofvars
. This construct applies also toRuleDelayed
,UpSetDelayed
, andTagSetDelayed
(short forms:>
,^:=
and/: :=
).The scoping construct must constitute the entire right hand side of the assignment or rule, and the
Condition
must constitute the entire body of the scoping construct, less any additionalCondition
applied to each.