From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e44577c74a66122 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-22 12:23:31 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn14feed!wn12feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc03.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: what's wrong with random References: <3e060eb9.4328921@news.freenet.de> X-Newsreader: Tom's custom newsreader Message-ID: <6bpN9.265045$pN3.20904@sccrnsc03> NNTP-Posting-Host: 12.234.13.56 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc03 1040588610 12.234.13.56 (Sun, 22 Dec 2002 20:23:30 GMT) NNTP-Posting-Date: Sun, 22 Dec 2002 20:23:30 GMT Organization: AT&T Broadband Date: Sun, 22 Dec 2002 20:23:30 GMT Xref: archiver1.google.com comp.lang.ada:32206 Date: 2002-12-22T20:23:30+00:00 List-Id: > >I think you want the generator to be global to Generate_FileName. > >Otherwise, it will be reinitialized each time Generate_FileName > > When I put > > subtype Int_Slice is Integer range valid_chars'range; > package My_Random is new Ada.Numerics.Discrete_Random (Int_Slice); > > into the function, nothing changes. Making the generator global to the function means making it outside the function, not moving the instantiation inside the function. Every time you execute the lines: > G : My_Random.Generator; > My_Random.Reset(G); it resets the random generator. You don't want it reset, you want it to continue with the next series of random numbers. So put those two lines outside the function. The first could go right after the "package My_Random ..." line and the Reset call could go before your function calling loop. The fact that a "delay" changes the behavior suggests that Reset is setting up a new starting value based on the clock. Since you get 5 or so duplicate strings when you don't have a "delay", it appears that your program is generating five strings in the time between clock ticks. The time between ticks is dependent on hardware, OS, and compiler, and the random number package may itself ignore the rightmost bits, so a "clock tick" could be a long time indeed.