RE : crazy run-time fluctuations (mostly super-slow) -- a bit more data



Sidney Marshall <sidneym at frontiernet.net> wrote:

   To compare random-states you need to use "equalp". Then the following
   works (typed directly to ACL):

Unfortunately, this is not true of portable ANSI Common Lisp.  Please
see the definition of equalp in the ANS, either the Hyperspec or

http://www.franz.com/support/documentation/current/ansicl/dictentr/equalp.htm

and see also the definition of the class random-state at

http://www.franz.com/support/documentation/current/ansicl/dictentr/random-s.htm

and finally the last paragraph of Type Relationships at

http://www.franz.com/support/documentation/current/ansicl/subsecti/typerela.htm

Now it happens that random-state is implemented in Allegro as a
structure-object, therefor two non-eq random-states can be compared with
equalp which will descend the corresponding structure slots testing for
equalp.  But even that doesn't guarantee that the equalp test is
meaningful, with the criterion being that calls to random using these
random states will yield that same results.  For example, the
random-state structure-object might be implemented with slots that are
irrelevant to the random function (e.g. a slot maintaining usage info
such as the number of times this random-state had been used) causing
false negatives.  Other plausible implementation techniques (which I
won't bother to sketch here) might result in false negatives.

In other words, the result of calling equalp on two random-state object
is unspecified (which in the language of the ANS means that the call
will be harmless and safe, but the returned value is not meaningful).

Now, why is my above rant relevant to Maxima?

Maxima is implemented in unfortunate territory.  Most of it has been
updated over time to be coded, more or less, on top of portable ANSI
Common Lisp.  For various reasons, the developer and user communities
want to keep it portable across several CL implementations.  This is IMO
a good idea, since it increases the range of platforms on which Maxima
will run, and especially because one expects there will soon appear a
portable CL running on tablets or smart phones.  Obviously not _all_ of
Maxima-supported CL implementations will appear on these platforms, but
being able to pull a Maxima platform out of one's pocket would be
science-fiction-worthy cool!  The portability of the Maxima kernel to
conforming CL implementations won't finess all the problems, of course,
since these portable devices often have small screens, and probably
won't implement a straightforward stdin/stdout I/O protocol -- these
things are outside the ANSI specification.  But still, it would be nice
if the essential Maxima kernel didn't need rewriting for _any_
conforming ANSI CL implementation.

That's why I suggest you and Olivier and all the other implementors
should not write code that depends upon equalp applied to random states.
It isn't portable, and even if every current implementation behaves as
desired, you'll run the risk of an unanticipated future change in one or
another implementation that will break the code, requiring tedious
debugging and gigabytes of discussion on the maxima list.