The tag has no wiki summary.

learn more… | top users | synonyms

3
votes
1answer
121 views

Functional programming for loop side effect

I am trying to get my head around as to why having a local variable or a for loop inside a function is not considered to be pure functional programming. Given this function: int as_int(char *str) { ...
3
votes
6answers
749 views

How can IO cause side effects in Functional Programming? [duplicate]

Whenever I read about Haskell, I find that IO can cause side effects. But I do not understand how it would do it? Do we mean that we are writing to a file from one lazy sequence and another lazy ...
11
votes
5answers
2k views

Why is reading from memory not a side-effect but reading from a file is?

What does exactly make reading from the process memory a pure operation? Suppose I created an array of 100 integers in the global memory and then took the 42th element of this array. It is not a side ...
4
votes
2answers
252 views

Alternative to language purity

Purity One of the interesting concepts in Haskell is the purity. However, I am wondering what the pragmatic reasons behind this is - let me explain a bit more before you reject my question. My main ...
9
votes
4answers
532 views

Is it ever OK for a conditional to have side effects? [closed]

I'm taking intermediate data structures course as a prereq for entry into the CS MS program at a University everyone in America has heard of. One line of code that was written in class caught my eye: ...
2
votes
2answers
283 views

Can referentially transparent functions have side effects?

I read everywhere that referential transparency and side-effects are mutually exclusive for all functions, however, what about the case in which a function changes some state that has no effect on its ...
6
votes
3answers
402 views

Side Effects Breaking Referential Transparency

Functional Programming in Scala explains a side effect’s impact on breaking referential transparency: side effect, which implies some violation of referential transparency. I’ve read part of ...
8
votes
2answers
390 views

Unit testing side effect-heavy code

I'm starting to write C++ code to run a robot, and I don't know how to incorporate unit testing, if indeed I can. I have been provided with a library which allows the creation of "commands" for the ...
15
votes
2answers
408 views

Side effect-free interface on top of a stateful library

In an interview with John Hughes where he talks about Erlang and Haskell, he has the following to say about using stateful libraries in Erlang: If I want to use a stateful library, I usually build ...
8
votes
2answers
419 views

Where do we put “asking the world” code when we separate computation from side effects?

According to Command-Query Separation principle, as well as Thinking in Data and DDD with Clojure presentations one should separate side effects (modifying the world) from computations and decisions, ...
6
votes
3answers
830 views

How is referential transparency enforced?

In FP languages, calling a function with the same parameters over and over again returns the same result over and over again (i.e. referential transparency). But a function like this (pseudo-code): ...
7
votes
2answers
674 views

Are side-effects in Array's “every”, or “some” bad?

I've always been taught that having side-effects in an if condition are bad. What I mean is; if (conditionThenHandle()) { // do effectively nothing } ... as opposed to; if (condition()) { ...
2
votes
2answers
317 views

I don't understand the definition of side effects [duplicate]

Possible Duplicate: What is a “side effect?” I don't understand the wikipedia article on Side Effects: In computer science, a function or expression is said to have a side effect if, in ...
21
votes
3answers
2k views

Different ways to see a monad

While learning Haskell I have faced a lot of tutorials trying to explain what are monads and why monads are important in Haskell. Each of them used analogies so it would be easier to catch the ...
7
votes
6answers
638 views

Does long term programming affect writing in a native spoken languages? [closed]

So, I am getting some years under my belt in long term programming. I have noticed, however, when the frequency and duration started increasing in my coding sessions that when I actually went to ...
13
votes
5answers
709 views

How to create scalable & side-effect free integration tests?

In my current project, I am having a hard time coming up with a good solution to create scalable integration tests that have no side effects. A little clarification on the side effect free property: ...
15
votes
5answers
2k views

Asynchronous Programming in Functional Languages

I'm mostly a C/C++ programmer, which means that the majority of my experience is with procedural and object-oriented paradigms. However, as many C++ programmers are aware, C++ has shifted in emphasis ...
33
votes
10answers
5k views

Why are side-effects considered evil in functional programming?

I feel that side effects are a natural phenomenon. But it is something like taboo in functional languages. What are the reasons? Edit: My question is specific to functional programming style. Not all ...