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=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,707e18bffca9c9cd X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.82.2 with SMTP id e2mr1829711pay.40.1344321533795; Mon, 06 Aug 2012 23:38:53 -0700 (PDT) Path: p10ni2817324pbh.1!nntp.google.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!ctu-peer!news.nctu.edu.tw!goblin2!goblin.stu.neva.ru!news.internetdienste.de!news.tu-darmstadt.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: question on using `with` without `use` and visibility of operators such as '*' Date: Mon, 30 Jul 2012 09:30:54 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 X-Trace: individual.net ehfBsYZXNaruT4ZpHQaJowU02u8vgnhy8uloJwewdpLgS9uzOcW/zjZM8cefEPmEVp Cancel-Lock: sha1:PSYUY2f7W/ijfT8zshZF389Z1nM= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Date: 2012-07-30T09:30:54+03:00 List-Id: On 12-07-30 09:04 , Nasser M. Abbasi wrote: > > > I prefer to use the long name of a package when I call some of its > functions. So I like to write > > ------------------------ > with package_foo; > package_foo.function_name(); > ----------------------- > > rather than > > ----------------------- > with package_foo; use package_foo; > function_name(); > ---------------------- > > So that when reading the code, I know where things are. > > This worked well so far, but when the package happened to export > functions/operators such as '*' or "+" for the types, then it will > not work any more. i.e. I really want to just write > > x * y > > where x,y are variables with types defined in the package, and not write > > x package_foo("*") y > > (or whatever the correct syntax would be) > > This is annoying. It means I have now to `use package_foo` > to be able to write x*y, since "*" is defined in the package. > > Is there a way around this, so I can avoid using `use` but still > be able to just write x * y (may be use something like > `use package_foo("*") at the top if this possible) Use "use type package_foo.T", where T is the type of x and y. Then you can apply the "primitive operators" of the type with qualifying with the package name. See the "use_type_clause" in http://www.ada-auth.org/standards/12rm/html/RM-8-4.html. Note the additional names made visible when the "all" keyword is placed between "use" and "type". -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .