Re: Two fixes I would like!
John M McIntosh <[email protected]>
| Newsgroups | gmane.comp.lang.smalltalk.squeak.foundation |
|---|---|
| Message-ID | <[email protected]> |
Hi, I've been distracted by chasing void is void, not int, and I'll throw this out for comment. I applied some serious thought here. First doing the UUIDGenerator class >>startUp Default := nil is correct only if you can ensure that a UUID isn't needed somewhere in the the startup process, the real issue is the Random number generator. One of the issues is that on the mac the millisecond clock starts from zero at application start time, so this code " Set a reasonable Park-Miller starting seed " [seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: self hash. seed = 0] whileTrue: ["Try again if ever get a seed = 0"]. is iffy because the probability that Time millisecondClockValue and self hash would be the same is quite good, maybe it should be " Set a reasonable Park-Miller starting seed " [seed := ((Time totalSeconds + Time millisecondClockValue) bitAnd: 16r3FFFFFFF) bitXor: self hash. seed = 0] whileTrue: ["Try again if ever get a seed = 0"]. Well that does do large integer math at some point but maybe we can ignore that issue. I'd also suggest saving the seed value in a instance variable and then in setupRandom check it against the old value and if we have a match which then of course means duplication and some type of recovery is needed. Mmm I'm not sure what tho, every 100,000 iterations we have an opportunity to reuse a previous seed, so does keeping one previous generation really help? But maybe it solves some issue at image restart? I might also suggest a RandomFromHostingOS class where one generates the random number? If you are going to the hassle of getting 4 random bytes, why not pull lots of them as needed from something that someone is worrying about being random and has certainly applied way more thought than us. Or would having a real UUID generator for linux is harder? Say ask RandomFromHostingOS isOk if true then use that instance versus Random. That way we could have that class work the details of bothering the hosting os for a good random number. Somehow that seems a more workable solution. PS You'll all should have noted the 100,000 Random instance regeneration I've in the code to avoid the issue that the sequence of random numbers from Random does repeat at some point... Which still has the flaw that we could repeat a sequence of 100,000 UUID. On Tuesday, December 3, 2002, at 11:52 AM, [email protected] wrote: -- ======================================================================== === John M. McIntosh <[email protected]> 1-800-477-2659 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ======================================================================== ===