From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Gnat bug or mistaken program?
Date: Wed, 21 Jul 2021 09:56:38 -0700 (PDT) [thread overview]
Message-ID: <6040e91a-fe01-447c-b508-174114f3101bn@googlegroups.com> (raw)
In-Reply-To: <sd8lsv$crp$1@dont-email.me>
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).
next prev parent reply other threads:[~2021-07-21 16:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-20 12:02 Gnat bug or mistaken program? Richard Iswara
2021-07-20 14:09 ` Niklas Holsti
2021-07-21 2:23 ` Richard Iswara
2021-07-21 8:29 ` Jeffrey R. Carter
2021-07-21 16:56 ` Shark8 [this message]
2021-07-22 2:14 ` Richard Iswara
2021-07-27 16:00 ` Niklas Holsti
2021-07-28 5:21 ` J-P. Rosen
2021-07-29 0:46 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox