Hacker News new | ask | show | jobs
by crc 5778 days ago
> 2. ubiquitous laziness can lead to some really subtle bugs

After the recent compiler change to prevent accidental head retention of lazy sequences, I don't remember having faced any subtle issue with laziness. Can you give me an example of what bit you?

1 comments

I don't have a concrete example at hand but the pattern is this:

1. program crashes with cryptic stack trace

2. add a println to look at the data

3. program crashes again, but can't print anything because lazy evaluation of something in the data structure triggers a new, different crash

So you've got an error you don't understand and you can't even look at the data you're working with so you start the hunt & peck procedure of trying to find the last point at which your data was sane so you can work back from there. Add dynamic typing to the mix and things get really ugly. I spent an hour tearing my hair out the other day when I inadvertently reversed the arguments to a function but didn't get an error until three function calls later because the types were duck-compatible that far.