Re: glib pseudo random number generator has landed.

On Fri, 9 Apr 1999, Sebastian Wilhelmi wrote:
> The pseudo random number generator for glib has landed. It is implemented
> in the file grand.c. Remaining issues are:
> 1. Is it possible to make glib dependent on '-lm' (the math lib), I would
>    like to add code to generate a normal distributed (as opposed to a
>    equal distributed random number). I need the math lib for that. The
>    code is uncommented for the time being. I'm willing to remove it, if
>    -lm is unwelcome (what I can perfectly comprehend).

This should be ok...  If systems are missing libm, you can easily
provide replacements using autoconf facilities.

Other comments:

* update the copyright for 1999.  I dunno what the 'official' position
on copyrights are, but I personally assign my public code to the Free
Software Foundation, as in gqueue.c.

I think there are some other Glib files which have been touched in
1999, but have not had their copyrights updated.

* using stdio in g_rand_new() seems like a lot of overhead.  wouldn't
open/read/close be better, since we have no need for stdio's buffering
in this case.

* it might be nicer to test for /dev/random in, and then
call [f]open on G_DEV_RANDOM.  That allows for any variance in the
naming of /dev/random facilities, and also allows you to omit the
/dev/random code completely on systems that do not support it.

* style issues...

	g_return_if_fail (rand != NULL);
is much more commonly found in Glib and GTK+ code than
	g_return_if_fail (rand);

* in glib.h, the typedef struct is typically found with other typedefs,
not with the function prototypes.

* in function declarations, the lack of parameters is prototyped using
void throughout glib.h, instead of the empty set:
	gdouble g_random_double        ();

* can you expand rand-test.c a bit?  :)  A good goal is to call each
public function [if possible], that at least assures all functions actually 

Overall, it's a welcome addition to Glib.  Thanks!


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]