On Friday, July 14, 2017 4:45:10 PM MDT Andrei Alexandrescu via Digitalmars- d wrote: > On 07/14/2017 04:29 PM, Jonathan M Davis via Digitalmars-d wrote: > > I'd guess that you'd use staticIndexOf an check for > > -1 to implement it > > Given that constraints are user-facing, having a forwarding one-liner > may be justifiable. -- Andrei
Possibly. It's hard to know sometimes when a one line wrapper is a big enough boost to usability to standardize. I could see this being such a case. staticIndexOf is a bit unwieldy, and I've rarely used it, but when I have, I think that I've always used it to check whether somehing is present rather than getting an actual index. Another tough example would be takeWhile/dropWhile. We already of until and find, which do the same things respectively but with the opposite predicate such that they're arguably too simple to be worth adding, but at the same time, if you have to negate your predicates often enough, having takeWhile and dropWhile would be a definite boon (also, for many folks, takeWhile and dropWhile are obvious in a way that until or find might not be - especially until). Timon was complaining bitterly the other day about the lack of takeWhile: https://issues.dlang.org/show_bug.cgi?id=4535 IIRC, I tried to add those several years ago, but you vetoed them on the grounds that simply negating the predicate was trvial, which is certainly true, albeit less user-friendly. I don't know what the correct answer is though. Sometimes, it's clear that adding a one-liner is a pointless wrapper, whereas in other cases, it seems like a definite usabiliy improvement. - Jonathan M Davis