side-effects Questions
6
Solved
I've been reading some JavaScript books and I always hear about closures and side effects. For some reason I can't understand what they really are. Can anyone explain to me what they are in plain E...
Prieto asked 14/11, 2011 at 22:27
2
Solved
As per the documentation on Oracle's website:
Side-effects in behavioral parameters to stream operations are, in general, discouraged, as they can often lead to unwitting violations of the state...
Sitnik asked 24/1, 2020 at 15:0
1
I'm reading 'Clean Code' from Robert C. Martin and I can't fully understand the 'Have No Side Effects' and 'Output Arguments' sections on pages 44 to 45.
In the 'Have No Side Effects' section it i...
Calisaya asked 18/1, 2020 at 13:31
5
According to the wikipedia entry for side effect, raising an exception constitutes a side effect. Consider this simple python function:
def foo(arg):
if not arg:
raise ValueError('arg cannot be ...
Bole asked 22/5, 2012 at 13:39
2
Solved
My question is about the following line of code, taken from "The C Programming Language" 2nd Edition:
*p++->str;
The book says that this line of code increments p after accessing whatever str...
Vernal asked 30/6, 2019 at 15:39
2
I've been trying to learn how to write code that is tree shaking friendly, but have run into a problem with unavoidable side effects that I'm not sure how to deal with.
In one of my modules, I acc...
Contravallation asked 26/2, 2019 at 5:45
1
Solved
I have an iterator and I would like to fold it with a nice method (say Iterator::sum):
let it = ...;
let sum = it.sum::<u64>();
Then I notice that I also need to know the number of element...
Cranberry asked 13/1, 2019 at 17:54
2
Solved
Given
pure id <*> v = v
holds, can pure do anything observable and not break the law?
If I define a type that encapsulates IO and say, spawn a new thread, is GHC free to optimize it away?...
Florencia asked 8/1, 2019 at 22:1
3
Solved
Run the following code:
// In Java, output #####
public static void main(String[] args) {
int i = 1;
if(i == (i = 2)) {
System.out.println("@@@@@");
} else {
System.out.println("#####");
}
...
Smoothtongued asked 2/12, 2018 at 5:41
1
Solved
I'm not new to Vue.js, but I'm going through the docs again, trying to pick up on anything I missed the first time. I came across this statement in basic example section of using computed propertie...
Mobster asked 22/9, 2018 at 15:36
2
In a Functional Programming book the author mentions the following are the side effects.
Modifying a variable
Modifying a data structure in place
Setting a field on an object
Throwing an except...
Turnstone asked 12/7, 2016 at 14:26
7
This is not a duplicate of Assignment inside lambda expression in Python, i.e., I'm not asking how to trick Python into assigning in a lambda expression.
I have some λ-calculus background. Conside...
Ailanthus asked 29/4, 2018 at 20:14
4
Solved
I'm trying to find out why the use of global is considered to be bad practice in python (and in programming in general). Can somebody explain? Links with more info would also be appreciated.
Skyscape asked 3/10, 2013 at 11:44
2
Solved
Webpack 4 has added a new feature: it now supports a sideEffects flag in the package.json of the modules it is bundling.
From Webpack 4: released today
Over the past 30 days we have worked clo...
Threw asked 7/3, 2018 at 20:35
1
Solved
In the mock, I want a certain function to return a new value in the test. This is how i did it.
Class MyClass:
my_var = None
def foo(self, var1):
return somevalue
def bar(self):
my_var =...
Hindustan asked 29/3, 2018 at 12:33
2
This is my first question to Stackoverflow, although I have been a consumer for many years. Please forgive me if I break rules. That is certainly not my intent. I have strenuously reviewed the rule...
Chyme asked 25/2, 2018 at 18:49
2
Solved
If a function's side effects are inherent within the design how do I develop such a function?
For instance if I wanted to implement a function like http.get( "url" ), and I stubbed the side effect...
Preservative asked 22/3, 2018 at 0:6
3
Solved
I create a class whose objects are initialized with
a bunch of XML code. The class has the ability to extract various parameters out of that XML and to cache them inside the object state variables....
Vostok asked 19/1, 2011 at 19:16
3
Solved
Does functional programming have a standard construct for this logic?
const passAround = (f) => (x) => {
f(x);
return x;
};
This enables me to compose functions that have side effects a...
Surfactant asked 8/9, 2017 at 12:27
2
Solved
I am C# dev that has just starting to learn F# and I have a few questions about unit testing. Let's say I want to the following code:
let input () = Console.In.ReadLine()
type MyType= {Name:strin...
Juieta asked 30/7, 2017 at 13:19
5
Solved
Is there a non-destructive way of deleting a key value pair from a hash?
For example, if you did
original_hash = {:foo => :bar}
new_hash = original_hash
new_hash = new_hash.reject{|key, _| key...
Restoration asked 21/11, 2012 at 2:53
3
Solved
I am trying to perform a simple side-effect in Kotlin:
fun handle(request: Request) {
repository.findByUID(request.userId)?.let {
if (someCondition) return
service.run(...)
}
}
As you can s...
Yvonneyvonner asked 28/12, 2016 at 9:18
2
Solved
I understand the appeal of pure functional languages like Haskell where you can keep track of side effects like disk I/O using monads.
Why aren't all system calls considered side effects? For exam...
Howund asked 30/11, 2016 at 17:24
10
Solved
Sometimes, an if statement can be rather complicated or long, so for the sake of readability it is better to extract complicated calls before the if.
e.g. this:
if (SomeComplicatedFunctionCall() ...
Escheat asked 17/10, 2016 at 8:3
3
Solved
Undefined behavior and sequence points
The link above is talking about sequence point and side effect in C++.
In a word, it means that between two sequence points, if we have more than one side e...
Clyve asked 6/10, 2016 at 2:9
© 2022 - 2024 — McMap. All rights reserved.