Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 60357

Use the [state] tag for questions pertaining to retained information determining the behavior of a program.

2 votes

Cleanest way to represent three states, where one can hold a Key/Value pair, and the other t...

In Java, we would use null for a free bucket, and the state of the bucket to mark it as occupied or deleted. …
amon's user avatar
  • 135k
1 vote
Accepted

Better to use Global Variable or Coroutine in general?

The coroutine approach is arguably worse because the coroutine state could change, whereas a global constant … well, stays constant. It's not shared global data that's a problem, but shared state. … Here, “state” is any data that changes over time. For a web application, any shared state belongs into a database or similar persistence mechanism. …
amon's user avatar
  • 135k
2 votes
Accepted

How to implement a counter without global state?

So instead of: State s; void some_function(void) { ... } int main() { some_function(); } You might have: void some_function(State* s) { ... } int main() { State s; some_function(&s); } If you … are concerned about concurrency issues that arise with shared state (not just global state), then using atomics for the counter could be appropriate. …
amon's user avatar
  • 135k
5 votes
Accepted

What's the proper way to think about state monads?

Ideally, state should not be an implicit global context, but an explicit parameter/return value of a function. So far, the theory. … Therefore, Haskell introduces the IO monad and the State monad to encode dependencies between effects on a type-system level. …
amon's user avatar
  • 135k
18 votes
Accepted

Stateful vs non-stateful app

Web app backends typically don't need to store any session state because they can use REST principles: state is transferred between the client and server. … In general, maintaining internal server state is fine when one of the following applies the state is stored externally the state is not shared between requests the state is just the acquisition of an …
amon's user avatar
  • 135k
10 votes

Does object-oriented programming allows side effects and state changes?

There are both examples where OOP involves state and examples where OOP is used without any state. … The program flow can then be interpreted as state transformations rather than state mutations. …
amon's user avatar
  • 135k
6 votes

Are there any drawbacks to partial application?

You are also concerned about using partial application in general, since this introduces hidden state. On one hand, this isn't an issue any more than creating objects. …
amon's user avatar
  • 135k
13 votes
Accepted

Side effect-free interface on top of a stateful library

retrieves the head: let rng = RNG(seed) let n : rng = rng in print n let n : rng = rng in print n let n : rng in print n With such an interface, we can always revert to a previous state
amon's user avatar
  • 135k
6 votes
Accepted

Is private global mutable state ever appropriate, namely when used to prevent API misuse?

.: module type Var = sig type typevar type state val newstate : () -> state val gensym : state -> some_type -> typevar val compare : typevar -> typevar -> bool end If reproducible type variable … IDs are not necessary, then keeping your solution with encapsulated global state is fine. …
amon's user avatar
  • 135k
8 votes
Accepted

Is it better to use lambda functions or boolean variables to record state

If you need a fancy name for what you are doing here, I suggest the State Pattern, with function objects representing the state. …
amon's user avatar
  • 135k
3 votes
Accepted

How to keep state alive between deployments

The trick is to not keep any session state within the stuff you redeploy. Instead: keep state in a separate database that persists beyond a deployment, or keep state purely client-side. … Where a web framework keeps state in-process or in tempfiles, a redeploy necessarily destroys that state. …
amon's user avatar
  • 135k