Is it a bad idea to return different data types from a single function in a dynamically typed language?
My primary language is statically typed (Java). In Java, you have to return a single type from every method. For example, you can’t have a method that conditionally returns a String
or conditionally returns an Integer
. But in JavaScript, for example, this is very possible.
How are atomic operations are a dynamic language feature?
I was told that atomic operations are a dynamic language feature. I was too afraid to ask in that context what this actually means because I didn’t want my coworkers to think I’m stupid. But I actually don’t really understand this statement.
How are atomic operations are a dynamic language feature?
I was told that atomic operations are a dynamic language feature. I was too afraid to ask in that context what this actually means because I didn’t want my coworkers to think I’m stupid. But I actually don’t really understand this statement.
How are atomic operations are a dynamic language feature?
I was told that atomic operations are a dynamic language feature. I was too afraid to ask in that context what this actually means because I didn’t want my coworkers to think I’m stupid. But I actually don’t really understand this statement.
How are atomic operations are a dynamic language feature?
I was told that atomic operations are a dynamic language feature. I was too afraid to ask in that context what this actually means because I didn’t want my coworkers to think I’m stupid. But I actually don’t really understand this statement.
How are atomic operations are a dynamic language feature?
I was told that atomic operations are a dynamic language feature. I was too afraid to ask in that context what this actually means because I didn’t want my coworkers to think I’m stupid. But I actually don’t really understand this statement.
Passing around impl-specific tokens in generic algorithms in a static/strong type system
I was interested in solving several unrelated problems using generic graph search techniques, so after some fiddling around I came up with the following design: have each problem implement a generic “Problem” interface which has an initial state, and several methods that take in states and moves, and return new states and moves. For example, I can getMoves(state)
, applyMove(state, move)
, or check isGoal(state)
. All of the problem specific details are then in one place, and the generic algorithms can pass around states and moves as generic “tokens” that they don’t really care about, using the Problem instance to evaluate their properties. The Problems are also consequently stateless (or what state they have is immutable), which makes their behaviour very easy to reason about.
Passing around impl-specific tokens in generic algorithms in a static/strong type system
I was interested in solving several unrelated problems using generic graph search techniques, so after some fiddling around I came up with the following design: have each problem implement a generic “Problem” interface which has an initial state, and several methods that take in states and moves, and return new states and moves. For example, I can getMoves(state)
, applyMove(state, move)
, or check isGoal(state)
. All of the problem specific details are then in one place, and the generic algorithms can pass around states and moves as generic “tokens” that they don’t really care about, using the Problem instance to evaluate their properties. The Problems are also consequently stateless (or what state they have is immutable), which makes their behaviour very easy to reason about.
Passing around impl-specific tokens in generic algorithms in a static/strong type system
I was interested in solving several unrelated problems using generic graph search techniques, so after some fiddling around I came up with the following design: have each problem implement a generic “Problem” interface which has an initial state, and several methods that take in states and moves, and return new states and moves. For example, I can getMoves(state)
, applyMove(state, move)
, or check isGoal(state)
. All of the problem specific details are then in one place, and the generic algorithms can pass around states and moves as generic “tokens” that they don’t really care about, using the Problem instance to evaluate their properties. The Problems are also consequently stateless (or what state they have is immutable), which makes their behaviour very easy to reason about.
How would I handle a set of differing event classes with differing handler interfaces in a single event processor?
I’m working on an event processor framework for a simple game I’m writing, in which multiple types of events are handled in a loop. Since these events carry distinct pieces of data (i.e. one carries a player and position, another carries a message and timestamp), I ended up creating different classes for them (though they still all implement a common interface, which is currently a marker interface).