On Tuesday, 10 April 2018 at 14:25:52 UTC, Nordlöw wrote:
Should ranges always provide a length property?
If so, in which cases is a length property an advantage or a requirement?
Just provide it whenever it is cheap to do so. If you need to do complex calculations or especially loop over contents to figure out the length, do NOT provide it.
But if it is as simple as returning some value, provide it and algorithms can take advantage of it for optimizations etc. as needed.