I've been propagating the new plrandd, plrandi and plseed functions to
some of the other language bindings in plplot. In the process I've made
a few observations. I was away and missed the original discussion of the
random number generator or I would have brought these points up then.

I should say I'm not a big fan of bloating the plplot library with
non-graphical routines, but the advantage of the random number generator
in terms of reproducible results across all bindings is certainly
worthwhile. 

1) plrandd and plrandi are the only API functions in the plplot with a
return value. All the pls* functions take pointers to variables to
return values. I'm sure this was all decided before my time. Others may
recall the precise reason. One advantage is that you can get back multiple
values. Anyway, perhaps for consistency the plrand? functions should
follow this convention. Personally I like functions with return values.
It makes it possible to use the functions for inline code (as in the
current C implementation of example 21. On the other hand it caused me
some problems with the fortran bindings as I had no templates to work
from! Fortran differentiates between subroutines (no return value) and
functions which do return a value. 

2) The types used by these functions are a bit loose. The use of unsigned
long (usually 64 bit on modern hardware) as the return value for plrandi
caused me some headaches with java until I realised that the return
value is actually a 32-bit unsigned integer. (Java has no concept of
unsigned type and so the largest positive integer you can have is
actually 63 bits with the long type - crazy, but there you are. See
google for the logic behind it.) We already have a PLUNICODE type which
is set up to be 32 bit unsigned on all platforms. I'm not suggesting 
that plrandi returns a PLUNICODE since that would be confusing but we 
could either rename PLUNICODE to something more generic, or make a new
type with the same logic (PLUINT32 perhaps?). The function plseed takes
an unsigned int as an argument, although internally it is an unsigned
long. The range is actually 32 bit unsigned as far as I can see. At 
least it should be consistent with plrandi, preferably with our new
"PLUINT32" type. Any thoughts?

Anyway, these comments aside, it is nice to finally have a uniform
version of example 21 to compare different bindings.

Andrew

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to