From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_05,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:6214:dcf:: with SMTP id 15mr1314256qvt.34.1626886598767; Wed, 21 Jul 2021 09:56:38 -0700 (PDT) X-Received: by 2002:a25:dc50:: with SMTP id y77mr47705067ybe.405.1626886598596; Wed, 21 Jul 2021 09:56:38 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!news.uzoreto.com!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 21 Jul 2021 09:56:38 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 146.5.2.231 References: <318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6040e91a-fe01-447c-b508-174114f3101bn@googlegroups.com> Subject: Re: Gnat bug or mistaken program? From: Shark8 Injection-Date: Wed, 21 Jul 2021 16:56:38 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:62420 List-Id: On Wednesday, July 21, 2021 at 2:29:22 AM UTC-6, Jeffrey R. Carter wrote: > > Thank you. So it is a visibility problem. > "Understanding visibility is the key to understanding Ada." -- /Ada Distilled/ > > Recommending the use package clause as a solution to a misunderstanding of > visibility is a disservice to a beginning user. Widespread application of use > pkg clauses is a crutch to avoid understanding visibility. I recommend that > those who do not understand visibility avoid the use clause altogether, as this > forces them to learn about visibility. When one understands visibility, one can > then make reasoned decisions about whether and when to add use clauses. > > In decreasing order of specificity, the ways to call an operation in a pkg are > > * Use the full name: Ada.Numerics.Elementary_Functions."**" (10.0, Logs) > This calls the operation once without changing its visibility > * Rename the operation: > function "**" (Left : Float; Right : Float) return Float renames > Ada.Numerics.Elementary_Functions."**"; > This makes the specific operation visible > * Use type: this makes all operators of the type visible (not applicable > in this case) > * Use all type: this makes all operations of the type visible (not > applicable in this case) > * Use package: this makes everything in the package visible > > Use pkg is clearly overkill for this case, and overuse of it can have negative > consequences. > > -- > Jeff Carter > "Choose a data representation that > makes the program simple." > Elements of Programming Style > 188 This is excellent advice and an good list, though the last element should be two or three: * Local, via declare-region/-scope; and * ["local" via usage inside the spec, (perhaps in the public portion, perhaps in the private); and] * Global (top of the file context-clauses).