by mehrdadn · 5y ago · 0 comments
P.S. (e) Is this sentinel-based approach even composable? If your iterator needs to use other iterators underneath, what do you do? You have to store a 'full' iterator anyway... or now you waste even more space and time storing a discriminated union. The fact that a range represents the whole sequence in one object instead of two makes composition intuitive and trivial.
Not 100% sure about the terminology. Pick whatever word might fit it better. I just called it a sentinel.
edit: looking at this it maybe covers it: