3 ms·
What does strict mean in this context? I don't know too much about these concepts. I think lazy means only evaluated when needed, like in generators (using Pyth
by vram22 10y ago
What does strict mean in this context? I don't know too much about these concepts. I think lazy means only evaluated when needed, like in generators (using Python as an example, which I know - I don't know Haskell or Idris). And I thought (from what little I've read), that the opposite of lazy evaluation was eager evaluation. So in Python at least, an example of eager vs. lazy would be returning a list vs. returning a generator from a function. For the former (list), the whole list would have to be created/populated and then returned (thereby occupying memory for the duration of its use), whereas for the latter (generator), items from it would only be yielded on demand, e.g. one at a time, when next() is called, or when the generator is iterated over, and so would not use as much memory as needed for the sum of the sizes of the items in the list. So where does strict fit in here?
Feel free to point if I've got any of the above wrong.
Update: Thanks for the replies, people.
- chongli 10y agoStrict evaluation is a synonym for eager evaluation. In Haskell, the primary mechanism for inducing evaluation is the case expression (if/then/else and pattern matching are syntactic sugar for case). Thunks (lazy expressions) in Haskell are created with let and then forced with case. It's very straightforward at the most basic level, there's just a lot of abstraction built on top of it that can obscure what's going on.
- laszlokorte 10y agostrict is same as eager and non-strict is same as lazy https://wiki.haskell.org/Lazy_vs._non-strict https://wiki.haskell.org/Lazy_vs._non-strict
- mrkgnao 10y agoI wrote this a while back. You might find it of some use. https://news.ycombinator.com/item?id=13907573 https://news.ycombinator.com/item?id=13907573
- vram22 10y agoIt was, thanks.