[Development] What to do with qrand/qsrand?
Olivier Goffart
olivier at woboq.com
Wed Jun 14 07:34:52 CEST 2017
Am Dienstag, 13. Juni 2017, 21:52:34 CEST schrieb Thiago Macieira:
> I've changed almost all uses of qrand in Qt sources to QRandomGenerator and
> eliminated the use of qsrand. That is actually the biggest advantage: not
> needing to seed the generator. I was quite surprised how much use of qrand
> we have in our own source code, and not just in examples. (See commits with
> Change-Id Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf).
>
> Obviously those functions need to remain in Qt 5, but what should we do to
> them long-term? See
> https://lxr.kde.org/ident?_i=qrand&_remember=1
>
> With this many references, I'm not sure we should even add a QT_DEPRECATED
> warning to it, since that would make trigger-happy "warning--" developers in
> KDE wholesale moving to something else.
Can you elaborate? Why would that be a bad thing?
> Options:
> 1) do nothing, leave as-is (in Qt 6, use thread_local)
>
> 2) deprecate and provide no replacement. That is, tell people to either:
> - use QRandomGenerator if they need true random, non-bulk
> - use <random> engines if they need bulk
> - use <stdlib.h> rand() if they need C library compatibility
>
> 3) deprecate and provide a thread-safe PRNG, which can be used in bulk
> a) with no seed; or
> b) with an access to seeding
>
> 4) same as #3, but actually use the qrand/qsrand names
> for (a), qsrand would be empty
More information about the Development
mailing list