Harman Patil (Editor)

Store passing style

Updated on
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Covid-19

Store-Passing Style is a programming technique that is used to model mutable state without using mutable state.

So, for instance, consider this JavaScript program, written in a non-store-passing-style:

This contains a reference to a global variable. In store-passing style, the value of the global variable (or variables) is passed along to each call, and also returned from each call and threaded through the next call. The code might look like this:

Note that each call takes an extra argument, and two values are now returned; the ordinary return value, and a new value representing the state of the formerly mutable variable.

Store-passing style can be quite painful to write, but can help to eliminate race conditions by isolating state within function calls, and can potentially make code more parallelizable.

References

Store-passing style Wikipedia


Similar Topics
Why Must I Die
Stuart Cameron
Archie Williams
Topics
 
B
i
Link
H2
L