4 ms·
Defining what a pure function in JavaScript is seems to be the difficult problem here. Maybe we should call a function pure if "given identical, pure arguments
by fmap 10y ago
Defining what a pure function in JavaScript is seems to be the difficult problem here.
Maybe we should call a function pure if "given identical, pure arguments, it returns identical, pure results". You would also need to define when an object is pure. That's already difficult, as the semantics of JavaScript objects are so weird. It's quite likely that we would have to replace "identical" by some weaker notion of relatedness which is merely preserved by "pure" functions...
Anyway, this might be useful as a static analysis for a JavaScript vm. It depends on how much wild JavaScript code is actually "pure" in any reasonable sense of the word. Let's just sum this up and say that JavaScript is really not a nice language to analyze.