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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,60e2922351e0e780 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-31 14:06:31 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshub.sdsu.edu!cyclone.bc.net!news.uunet.ca!nf3.bellglobal.com!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail From: "Warren W. Gay VE3WWG" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Clause "with and use" References: <3FA2CDCB.500F4AF0@fakeaddress.nil> In-Reply-To: <3FA2CDCB.500F4AF0@fakeaddress.nil> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 31 Oct 2003 16:51:45 -0500 NNTP-Posting-Host: 198.96.223.163 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1067637074 198.96.223.163 (Fri, 31 Oct 2003 16:51:14 EST) NNTP-Posting-Date: Fri, 31 Oct 2003 16:51:14 EST Organization: Bell Sympatico Xref: archiver1.google.com comp.lang.ada:1878 Date: 2003-10-31T16:51:45-05:00 List-Id: Gautier Write-only wrote: > Peter Hermann's post about number_base reminds me on a suggestion of mine > about a "with and use" clause in AC ! Comments are welcome... > Original proposal follows: > ____ > > Proposal for a "with and use" clause > > Hello! > > Almost the only thing I find tedious in Ada is the obligation > to name twice packages you intend to _use_ in a context_clause. > I illustrate with examples two usual ways of organizing context clauses: > > (A) > > -- (1) With'ed only > with Ada.Command_Line; > > -- (2) With'ed and Use'd > with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO; > use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO; I don't like use-ing everything that is with-ed. I prefer to name the packages to use in the procedure/declare blocks. > Problem: in practice the list pair (2) is a lot longer (many many lines) and > becomes difficult to synchronize. It is also difficult then to > _verify_ that the pair is consistent True, but you need it for full control. Sometimes, you need to omit certain use-es. > (B) > > -- (1) With'ed only > with Ada.Command_Line; This is generally the approach I use now. With only a few exceptions, I just put use clauses in the procedure/begin block where it is used. This avoids a whole lot of evil, and permits greater freedom in using commonly used names. > -- (2) With'ed and Use'd > with Ada.Text_IO; use Ada.Text_IO; > with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; > with Ada.Float_Text_IO; use Ada.Float_Text_IO; > > Advantage: much easier to verify and transport across sources > Problem: the beginning of sources becomes awfully long. I know this is a contraversial subject (no agreement will follow), but I believe for larger projects at least, this is a poor practice to follow (this goes for (A) as well). > To sum up, I'd describe the current situation so > > - beginner-repellent and newcomer-repellent (not to be neglected !) > - ugly > - redundant > - causes a readability problem and possible confusions > - pushes the real thing, i.e. the programming contents after > "procedure/package... is", too far away of the source's top > - needs too much administration > > My proposal: a "with and use" clause. "with and use A[,B]" would > mean "with A[,B]; use A[,B]". > > (C) > > -- (1) With'ed only > with Ada.Command_Line; > > -- (2) With'ed and Use'd > with and use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO; What about A.B.C packages? Are you implying each level should be used as well? Overall, I think this is a bad plan. Just my $0.02 worth (and the Cdn $ is gaining strength again against the US $ ;-) -- Warren W. Gay VE3WWG http://home.cogeco.ca/~ve3wwg