You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An immutable class already implies that its methods are pure, but sometimes we're only interested in the purity of a single method of an otherwise mutable class.
Basically we would need to check that for the same params (fields?) the return value is the same.
We should allow reads of immutable class state, but not of mutable ones (unless configured explicitly to allow that);
We should allow field writes of newly created objects (the ones we can trace) but not class state (except for lazy init maybe);
We should allow (configurable?) static reads, but not writes;
Open question:
Can we handle reflective calls reliably?
What's a pure constructor?
doesn't write static state
doesn't call impure methods (e.g. Random)
can write local state and throw exception
Whitelistable native calls with several severities:
String::internand Object.getClass are basically caching
System::arraycopy is basically pure, but instead of returning it modifies the inputs
Unlike e.g. System::nanoTime which is never pure
When does UNSAFE usage invalidate purity?
Is it pure if throwing depends only on local state (i.e. is predictable)?
Can non-empty void methods therefore be pure?
Check asserts or logging or caching?
Class init and static init blocks - similar to caching
Local purity - if run on the same computer (architecture), it returns the same result?
Are utility classes (no class state, just static methods) immutable, if any of the methods mutates the parameters (e.g. Arrays#sort)
The text was updated successfully, but these errors were encountered:
An immutable class already implies that its methods are pure, but sometimes we're only interested in the purity of a single method of an otherwise mutable class.
Basically we would need to check that for the same params (fields?) the return value is the same.
Open question:
Random
)String::intern
andObject.getClass
are basically cachingSystem::arraycopy
is basically pure, but instead of returning it modifies the inputsSystem::nanoTime
which is never pureUNSAFE
usage invalidate purity?The text was updated successfully, but these errors were encountered: