[Issue 9102] OutputRange should be ref parameter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 25 04:21:04 PST 2013


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


Johannes Pfau <johannespfau at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johannespfau at gmail.com


--- Comment #5 from Johannes Pfau <johannespfau at gmail.com> 2013-02-25 04:21:01 PST ---
This problem was already mentioned in the review, however no good solution was
found. I don't think it's as simple as saying CRC32 is not a valid OutputRange.
I haven't found any public documentation stating that a OutputRange cannot be a
pure value type or some similar note.

The big question "What type of range is passed by ref/auto ref/value" has not
been answered in any way, phobos sometimes uses pass by value, pass by ref,....

If you're saying OutputRanges shouldn't be passed by ref you're also saying put
is wrong as it does take it's range parameter by ref. This needs some
discussion though, cause last time copy was considered to be wrong.


Anyway, for std.digest a good name for put would be update, that's what's used
in other libraries. But I don't know if we can still break the API.

A nicer solution is to prevent creating copies of this type. IIRC this can be
done with a disabled postblit. Creating a copy is dangerous in any case and we
even have some examples with comment "Do not pass by value". Creating bit
copies of hashes wasn't officially supported so it's not a real API breakage.
CRC32 could still be used with functions which do take OutputRanges by ref,
passing it to ref functions would work and CRC32OutputRange is not necessary,
as CRC32* can be used (think of new CRC32()...)

-- 
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