[Issue 10868] std.string.translate should take an optional buffer

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 21 22:59:35 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10868



--- Comment #3 from Jonathan M Davis <jmdavisProg at gmx.com> 2013-08-21 22:59:34 PDT ---
IIRC, it's come up before (with the digest stuff? - I know the issue of a
function to "finish" came up for that), but I don't recall any resolution of
it. I believe that with regards to arrays at least, if you use them as an
output range, you can check for full by checking that length != 0, and length
effectively ends up giving you how much left you can write to, but even if that
holds in general, not all ranges can tell you how much they can be written to
them as opposed to whether they're full, which IIRC led to discussions of the
case where you try and put more elements than can fit at once (e.g. if you have
1 char left in a char[] and try and put a character takes up 3 code units), and
that almost requires that you end up throwing in put in some cases rather than
being able to check for space ahead of time, which is problematic (though maybe
put could be changed to return whether it succeeded in order to deal with the
case where you might be able to put more than it could fit and can't check
first).

In any case, it obviously gets a bit nasty, and we probably should discuss it
again. I'll try and organize my thoughts on it a bit and create another thread
on the topic, since we do need to iron out these issues if we want to use
output ranges heavily (which we should be moving to at least as an overload for
many/most functions which allocate). Output ranges have suffered from a lack of
attention and probably should have been discussed more or thought through more
before being added. But at least output ranges are used enough less than input
ranges that it's probably nowhere near as big a deal to break their API if we
have to (especially if at least some of the missing functions can be given
generic versions via UFCS).

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


More information about the Digitalmars-d-bugs mailing list