Why is seq bad?

As far as I know a polymorphic seq function is bad because it weakens free theorems or, in other words, some equalities that are valid without seq are no longer valid with seq. For example, the equality map g (f xs) = f (map g xs) holds for all functions g :: tau -> tau’, … Read more

Lazy evaluation in Python

The object returned by range() (or xrange() in Python2.x) is known as a lazy iterable. Instead of storing the entire range, [0,1,2,..,9], in memory, the generator stores a definition for (i=0; i<10; i+=1) and computes the next value only when needed (AKA lazy-evaluation). Essentially, a generator allows you to return a list like structure, but … Read more

Do the &= and |= operators for bool short-circuit?

From C++11 5.17 Assignment and compound assignment operators: The behavior of an expression of the form E1 op = E2 is equivalent to E1 = E1 op E2 except that E1 is evaluated only once. However, you’re mixing up logical AND which does short-circuit, and the bitwise AND which never does. The text snippet &&=, … Read more

How does non-strict and lazy differ?

Non-strict and lazy, while informally interchangeable, apply to different domains of discussion. Non-strict refers to semantics: the mathematical meaning of an expression. The world to which non-strict applies has no concept of the running time of a function, memory consumption, or even a computer. It simply talks about what kinds of values in the domain … Read more

Is it bad practice to have my getter method change the stored value?

I think it is actually quite a bad practice if your getter methods change the internal state of the object. To achieve the same I would suggest just returning the “N/A”. Generally speaking this internal field might be used in other places (internally) for which you don’t need to use the getter method. So in … Read more