digitalmars.D - Rationale for no opIndex, length in std.algorithm.map?
- dsimcha (8/8) May 13 2009 What is the rationale for lack of opIndex and length in map? opIndex mi...
- Andrei Alexandrescu (6/14) May 13 2009 It's an oversight. map should offer opIndex and length iff the mapped
What is the rationale for lack of opIndex and length in map? opIndex might be a bad idea if the function being mapped is expensive, but it's not so bad if the function is cheap. Length just seems like a no-brainer to me if the underlying range has a length. There are several places in various code I've written where I need to copy an arbitrary range, or some transform of it, to an array, and this obviously can be done more efficiently when the length is known in advance. Were these just oversights, and should an enhancement request be filed, or is there a good reason for excluding them?
May 13 2009
dsimcha wrote:What is the rationale for lack of opIndex and length in map? opIndex might be a bad idea if the function being mapped is expensive, but it's not so bad if the function is cheap. Length just seems like a no-brainer to me if the underlying range has a length. There are several places in various code I've written where I need to copy an arbitrary range, or some transform of it, to an array, and this obviously can be done more efficiently when the length is known in advance. Were these just oversights, and should an enhancement request be filed, or is there a good reason for excluding them?It's an oversight. map should offer opIndex and length iff the mapped range offers them. Could you please bugzilla that? Andrei P.S. I appreciate the great work you're doing. Good going!
May 13 2009