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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.unit0.net!news.uni-stuttgart.de!news-1.dfn.de!news.dfn.de!news.uni-weimar.de!medsec1.medien.uni-weimar.de!slucks From: Stefan.Lucks@uni-weimar.de Newsgroups: comp.lang.ada Subject: Re: some trivial questions? Date: Thu, 2 Nov 2017 09:39:29 +0100 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <6a5368c5-f015-4dcb-9291-e77b40fa1bf1@googlegroups.com> NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-1656724652-1509611970=:20673" X-Trace: pinkpiglet.scc.uni-weimar.de 1509611971 1057 141.54.178.228 (2 Nov 2017 08:39:31 GMT) X-Complaints-To: news@pinkpiglet.scc.uni-weimar.de NNTP-Posting-Date: Thu, 2 Nov 2017 08:39:31 +0000 (UTC) X-X-Sender: slucks@lucks-pc In-Reply-To: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Xref: news.eternal-september.org comp.lang.ada:48699 Date: 2017-11-02T09:39:29+01:00 List-Id: --8323329-1656724652-1509611970=:20673 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Wed, 1 Nov 2017, tclwarrior@gmail.com wrote: > i meant to say, why doesn't "use" imply "with" i think every time you=20 > insert a use, you will most definitely add a with Well, in short textbook examples you will find something like "with Ada.Text_IO; use Ada.Text_IO", as the so-called "context clause" (the first few lines of code, with only= =20 "with" and "use" clauses). But you should not extrapolate to larger programs. You may have to "with"= =20 plenty of packages. But if they "use" more than one or two of them in the context clause, the readability of your program quickly declines.=20 It can be quite hard to figure out to which package a certain subprogram=20 you are calling belongs to. It is often better to "use" libraries locally, rather than in context=20 clauses. On the other hand, to "use" them (or to use them without a "use"= =20 clause), you must always "with" them in the context clause. You could say, the "with"s in the context clause define the dependencies of your program. Variant 1: use in context clause: with Ada.Text_IO; use Ada.Text_IO; procedure Hello_World is begin Put_Line("Hello World!"); end Hello_World; Variant 2: "use" local with Ada.Text_IO; procedure Hello_World is use Ada.Text_IO; begin Put_Line("Hello World!"); end Hello_World; In thsz example, the difference between context-clause "use" and local=20 "use" does not really matter. But if you have a bigger package, it greatly= =20 improves the readability to "use Ada.Text_IO" only in those subprograms,=20 which actually perform textual IO. Same for "use"ing other packages in=20 other subprograms, of course. > i think in a program with a large import (use) list of libraries, this ca= n > save many lines and looks cleaner As I worte before: You may have to "with" a long list of libraries, but=20 you should never "use" more than one or two of them in the context clause. -------- I love the taste of Cryptanalysis in the morning! -------= - www.uni-weimar.de/de/medien/professuren/mediensicherheit/people/stefan-luck= s ----Stefan.Lucks (at) uni-weimar.de, Bauhaus-Universit=C3=A4t Weimar, Germa= ny---- --8323329-1656724652-1509611970=:20673--