| Date: Tue, 31 Aug 2010 09:49:33 -0300 | From: Jeronimo Pellegrini <[email protected]> | | I was wondering if it isn't worth to include the timing part of | SRFI-18 in the small version of Scheme. The procedures that I | suppose would be interesting are: | | - (current-time) | - (time->seconds time) | - (seconds->time x) | - (time? obj) | | Just that. No threads, mutexes or signals. | | The reason for this is that those procedures would be useful | to implement two important didactic examples: | | - A PRNG: | I agree with those that think that including simple randomness | in "small" Scheme is not encessary, since it's easy to write a | PRNG that would work fine for didatic purposes: a linear | congruential PRNG is trivial to write, easy to understand and | a nice example of procedure. It's also a nice example of a | referentially transparent procedure if you don't hide its | state -- and later in the course it's possible to talk about | encapsulation of state using it again as an example. | However, it would be good to have some way to seed the PRNG | with a minimally unpredictable number, which could be obtained | from (time->seconds (current-time)) (for simple randomness | for students this is usually good enough).
Linear-congruential PRNGs do not pass Marsaglia's (Diehard) PRNG tests. RC4, which is as easy to write as LCPRNGs and is included in SLIB, does pass Diehard <http://people.csail.mit.edu/jaffer/slib_5.html#SEC119>. RC4 does 5 byte reads, a byte addition, and 5 byte writes per byte of output. RC4 effectively computes a cryptographic hash of its key; you can't improve on that. We do students no favor by getting them accustomed to the flawed PRNGs from the twentieth-century. _______________________________________________ Scheme-reports mailing list [email protected] http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports
