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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!rpi!zaphod.mps.ohio-state.edu!samsung!emory!mephisto!prism!jm21 From: jm21@prism.gatech.EDU (Jim Marks) Newsgroups: comp.lang.ada Subject: Re: Unusual "use" semantics Summary: Nothing unusual Message-ID: <12342@hydra.gatech.EDU> Date: 8 Aug 90 22:37:00 GMT References: <20@polymnia.tsd.arlut.utexas.edu> Distribution: usa Organization: Georgia Institute of Technology List-Id: In article <20@polymnia.tsd.arlut.utexas.edu> fred@polymnia.tsd.arlut.utexas.edu (Fred Hosch) writes: >My Ada compiler complains about the relation on the fourth line of the >following > > with TEXT_IO; > procedure TEST is > begin > if TEXT_IO.COL = 1 then >... > >reporting: no operator visible for positive_count "=" universal integer. > >If I add a context clause "use TEXT_IO;" it compiles successfully. > This is a result of the strong typing and operator overloading of Ada. The "=" operator you have visible can take two integer type arguments. However, the return value of TEXT_IO.COL is of type POSITIVE_COUNT, which is a subtype of type COUNT, declared in the Text_IO package (LRM 14.3.10). This type has its own "=" operator implicitly declared for it in Text_IO. When you include the "use" clause for Text_IO, then the "=" operator for this type (COUNT) is then visible (in this case, the "1" is considered of this type so that it matches). You could also do the following: if integer(Text_IO.Col) = 1 then ... which converts the return value to integer, OR if Text_IO."=" ( Text_IO.Col , 1 ) then ... which is UGLY. I've had this problem many times when I don't think about it in advance. This is a good application of the "use" clause, even though some coding standards discourage (or prohibit) the use of "use" clauses. -- Jim Marks | Georgia Tech Research Institute Compuserve: 72310,2410 | Concepts Analysis Laboratory Internet: jm21@prism.gatech.edu -or- jmarks@gtri01.gatech.edu