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.9 required=3.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!mRBVMlGoFUnDsRgMYRJiSw.user.46.165.242.75.POSTED!not-for-mail From: Richard Iswara Newsgroups: comp.lang.ada Subject: Re: Gnat bug or mistaken program? Date: Thu, 22 Jul 2021 09:14:29 +0700 Organization: Aioe.org NNTP Server Message-ID: References: <318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com> <6040e91a-fe01-447c-b508-174114f3101bn@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="52743"; posting-host="mRBVMlGoFUnDsRgMYRJiSw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:62421 List-Id: On 21/07/2021 23.56, Shark8 wrote: > 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). > Thank you all for your tips and explanations.