On Sun, 9 Sep 2001, Jeroen van Wolffelaar wrote:

> >     Well, I didn't see them agree to all that, but... You also can't
> >     really say rand() isn't thread safe.  It is thread safe on quite a
> >     few platforms,
>
> rand() isn't thread safe, but only very few platforms (i.e., Microsoft's ISS
> etc) use threads. Apache does not use threads, so it has no problems with
> non-thread safe code.
> Agreed, this can be fixed without changing implementation.
>

    Yes, on some systems it is thread safe, to my knowledge, and as I
    said, rand_r() solves this on systems it isn't.

> >     and if we switch to rand_r() it will be thread-safe
> >     on most other platforms.  How is it difficult to use for newbies?  I
> >     really don't see that many support requests coming in regarding
> >     random number functionality.
>
> Just because people simply don't notice it isn't random :-). That's inherent
> to the nature of the function... you won't see it's wrong - easily. It is
> simply needless complicated now, as Zeev says, we shouldn't be handling the
> subject in such a techie manner. See also below.
>

    No number is truly random.  That is the nature of computers.  You
    can only generate a sequence of numbers, based on a seed.

> >     mt_rand() is fine as an alternative, but I'd prefer to keep the
> >     system rand() as the default.
>
> The pointe is that you can choose. And I really don't see why you should
> keep an inferior algorithm as default... please explain?
>
    That's your opinion.  Why do we have to change it, when people have
    been using it happily for all these years.

> > > And I also said before that wether or not is should be a redesign will
> be
> > > discussed AFTER it has been agreed how the functions will behave in the
> > > future. It is more helpful by the way if you comment on the separete
> points
> > > in the proposal, which points don't you like?
> > >
> >
> >     What I see as something acceptable:
> >
> >     1)  Switch most of the functions to use the mt_rand functions, as
> >     you see, i've made the latest CVS export these functions, so its
> >     just a matter of changing the function names in the source.
> >
> >     2) Automatically generate the seed's, I'm not sure whether this
> >     should be done at module init or put a test in each function.  Then
> >     just make the call to [mt_]srand() optional.
> >
> >     An easier way around this might just be to make the argument to
> >     srand() optional, ie:
> >
> >     srand();
> >
> >     Would just use the most random seed possible.
>
> I completely agree that that is the minimun that should be done. As you
> know, IMHO more should be done. The major reason I wanted this is to have
> the possibility to add extra random number generators, to start with, add
> the lcg generator to it, since it is simply just-another-generator!
>

    When you add another two functions, now we have a rand() and a
    random() functions, the latter fixing non-existant bugs in the
    former.

    My god, this is generating a random number, its nothing that
    complex, so lets not make it such.  And, btw, if you want to use lcg,
    just use the lcg_value() function.

    We don't need PHP to support 15 different algorithms for generating
    random numbers, if you want that, move it into a php extension, but
    it doesn't belong in the core.

> My proposal reduces the namespace-load to PHP to 2: random and set_random.
> If you want random numbers, you only have one function: random. If you place
> set_random at the top of any script, you will see that it garantees that the
> script will act identically on each call, because set_random controls all
> random!
>
> IMHO the power of PHP is it's intuitiveness in using it, and I don't think
> mt_srand(); mt_rand() is intuitive.
>

    Really, then why hasn't anyone complained as of yet?  And this is the
    way it is done in other languages as well (C, Perl, Python).  Why
    change what's working?  If you really want, create a new extension,
    distributed externally, just like Perl has the Math::TrulyRandom
    module.

> > > Please understand me right, I find it very useful to have someone
> critically
> > > look at my proposal, but please be more specific.
> > >
> >     Right, those more specific comments belong on list :)
>
> I didn't Cc to php-dev, since I could be breaking the law... but you may
> forward this mail to it :-)
>

    I am. ;)

    -Sterling


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to