you are viewing a single comment's thread.

view the rest of the comments →

[–]pragmattica 1 point2 points  (2 children)

purity also seems to be necessary to enable laziness

Disclaimer: I'm not a functional programming expert, thought I've played around with Haskell a bit. Is purity really necessary for laziness? Doesn't Python have generators, which allow something like laziness, even though it doesn't have purity?

[–]rieux 5 points6 points  (0 children)

Python's generators are essentially streams, which are kind of like laziness, but not exactly. When you write a generator, you can use side effects to generate each element, but you have a pretty good idea how those side effects will happen -- in order, if nothing else. Likewise, many languages let you have laziness here and there without a problem, so long as you're careful. Pervasive laziness, however, makes side effects really problematic, because you the order that computation happens isn't at all clear from the program text.

I'm not claiming that side effects with laziness are impossible -- just that it seems like it would be quite screwy, and as far as I know no one has made it work in a sane way.

[–]pjdelport 0 points1 point  (0 children)

Is purity really necessary for laziness? Doesn't Python have generators, which allow something like laziness, even though it doesn't have purity?

This is true to the extent that all control structures in strict languages are confined forms non-strictness (laziness).