[Issue 5530] std.algorithm.len()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 25 15:31:09 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=5530



--- Comment #3 from Peter Alexander <peter.alexander.au at gmail.com> 2014-01-25 15:31:05 PST ---
(In reply to comment #2)
> (In reply to comment #1)
> > What's wrong with `walkLength`?
> 
> Its semantics and performance are different for narrow strings, that are common
> use case. len is O(1), walkLength is sometimes O(n).

So am I right in saying that your proposed 'len' function would return .length
for narrow strings?

If that's the case then it would be a glaring inconsistency with the rest of
Phobos, which has been very careful to treat strings as ranges of code points,
and not code units. Having a single function break consistency for the sake of
a few characters of typing convenience doesn't seem like a sensible thing to
do.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list