Skip to content

re: Principles of Functional Programming VIEW POST

re: I agree that this isn’t good code or practice to use in a production environment and if seen in the wild it should be refactored but that was the p...

Furthermore the example isn’t my own

Really doesn't matter. I was commenting about the example, not about you :)

The aim is to let potentially inexperienced readers know that this is typically not OK.

The other point of consideration is that in some environments it is unavoidable to have mutations to the inputs

Unfortunately, yes.

and so clones and copies become the default solution to avoid mutation to the original values which this example showcases.

I would also like the readers to understand that it's more of a workaround than a solution.

“I would also like the readers to understand that it's more of a workaround than a solution.” - only if it’s avoidable since in the environments where we can’t have proper immutability this is the solution.

Fair enough, it’s a point though. Thanks for the comments!

Mmm.. interesting philosophical topic. I really need to think about it. Thinking here now. I would say that it's a workaround, which is the appropriate solution for the situation (as opposed to refactoring the original function, which is not possible).

Keeping it in mind and in comments as "workaround" should potentially push more towards the "real" solution when it becomes possible.

I guess "workaround" is specific type of solution in this situation. Between two words when one is more specific, I choose the specific one unless I specifically want to generalize.

code of conduct - report abuse