Why are assignments not allowed in Python’s `lambda` expressions?

The entire reason lambda exists is that it’s an expression.1 If you want something that’s like lambda but is a statement, that’s just def. Python expressions cannot contain statements. This is, in fact, fundamental to the language, and Python gets a lot of mileage out of that decision. It’s the reason indentation for flow control … Read more

Javascript closures and side effects in plain English? (separately)

Side effects are the easier concept. A “pure function” is a function that maps its input value(s) into an output value function plus(x, y) { return x + y; }. A “side effect” is any effect other than that return value. So, for instance: function plusWithSideEffects(x, y) { alert(‘This is a side effect’); return x … Read more

What are the alternative of monads to use IO in pure functional programming?

What alternatives are there to monads for I/O in a pure functional language? I’m aware of two alternatives in the literature: One is a so-called linear type system. The idea is that a value of linear type must be used exactly one time: you can’t ignore it, and you can’t use it twice. With this … Read more

Is the use of del bad?

The other answers are looking at it from a technical point of view (i.e. what’s the best way to modify a list), but I would say the (much) more important reason people recommend, for example, slicing, is that it doesn’t modify the original list. The reason for this in turn is that usually, the list … Read more

Why is the raising of an exception a side effect?

Purity is only violated if you observe the exception, and make a decision based on it that changes the control flow. Actually throwing an exception value is referentially transparent — it is semantically equivalent to non-termination or other so-called bottom values. If a (pure) function is not total, then it evaluates to a bottom value. … Read more

Purity vs Referential transparency

If I gather in one place any three theorists of my acquaintance, at least two of them disagree on the meaning of the term “referential transparency.” And when I was a young student, a mentor of mine gave me a paper explaining that even if you consider only the professional literature, the phrase “referentially transparent” … Read more

What Does Webpack 4 Expect From A Package With sideEffects: false

Sean from the webpack Team! I’ll do my best in lieu of our documentation still in progress to answer your question here! According to the ECMA Module Spec (I’m not going to try and find the link so you’ll have to trust me here because it’s buried), whenever a module re-exports all exports, (regardless if … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)