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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.140.157.74 with SMTP id d71mr28189023qhd.13.1447642401011; Sun, 15 Nov 2015 18:53:21 -0800 (PST) X-Received: by 10.182.246.66 with SMTP id xu2mr296217obc.18.1447642400975; Sun, 15 Nov 2015 18:53:20 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!i2no3379111igv.0!news-out.google.com!l1ni5812igd.0!nntp.google.com!i2no3379107igv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 15 Nov 2015 18:53:20 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:18f:900:8350:ba86:87ff:fed6:5907; posting-account=AvekzAoAAABj-TclKcOWQmXwA49MFPGX NNTP-Posting-Host: 2601:18f:900:8350:ba86:87ff:fed6:5907 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Generating a random number, not sure why I'm getting this error From: John Smith Injection-Date: Mon, 16 Nov 2015 02:53:20 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:28385 Date: 2015-11-15T18:53:20-08:00 List-Id: On Sunday, November 15, 2015 at 9:29:06 PM UTC-5, Jeffrey R. Carter wrote: > On 11/15/2015 06:25 PM, John Smith wrote: > > > > with Ada.Numerics.Discrete_Random; ... > > Ada.Numerics.Discrete_Random.Reset(Ada.Numerics.Discrete_Random.Generator); > > Generator is a type, not something you can pass to a subprogram. What would you > expect a call to Random to return? > > > And this is the error that I get: > > > > :13:15: invalid prefix in selected component "Ada.Numerics.Discrete_Random" > > -- refers to the first Ada.Numerics.Discrete_Random... > > Not a great error msg. > > Discrete_Random is not a package: it's a generic package. You can consider a > generic like a template for a package or subprogram. You create a package or > subprogram from the generic through what Ada calls instantiation. When you > instantiate Discrete_Random, you supply a discrete subtype to fill in for > Result_Subtype; Random returns a value of this subtype. > > So, for example, > > package Random is new Ada.Numerics.Discrete_Random (Result_Subtype => Character; > -- Random is the name of the pkg created by the instantiation > > Gen : Random.Generator; > C : Character; > > Random.Reset (Gen => Gen); > C := Random.Random (Gen); > > -- > Jeff Carter > "Apart from the sanitation, the medicine, education, wine, > public order, irrigation, roads, the fresh water system, > and public health, what have the Romans ever done for us?" > Monty Python's Life of Brian > 80 Ok, that's what I was missing. I didn't realize that that was how generic packages should be used. I figured that they should be used just like any other package. Thank you.