comp.lang.ada
 help / color / mirror / Atom feed
From: kolender@ics.uci.edu (Kurt Olender)
Subject: Re: Unusual "use" semantics
Date: 9 Aug 90 16:15:16 GMT	[thread overview]
Message-ID: <KOLENDER.90Aug9091638@gambetta.ics.uci.edu> (raw)
In-Reply-To: fred@polymnia.tsd.arlut.utexas.edu's message of 8 Aug 90 21:21:51 GMT


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
		   TEXT_IO.PUT_LINE ("COL is 1");
	       else
		   TEXT_IO.PUT_LINE ("COL is not 1");
	       end if;
	   end TEST;

   reporting: no operator visible for positive_count "=" universal integer.

There is one other solution that hasn't been put forward that avoids both the
"ugliness" of calling text_io."="(...) and the "use" clause, a rename
statement, as follows:

     function "=" (a, b: text_io.positive_count)
	      return boolean
	      renames text_io."=";


You may then write

    if (text_io.col = 1) ...

and the compiler will have a visible comparison operator for positive count.

I prefer this method, even though it involves more typing, because it
explicitly makes visible only those things you really need to be visible, and
reduces the potential name clashes that "use" can cause.

  parent reply	other threads:[~1990-08-09 16:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-08-08 21:21 Unusual "use" semantics Fred Hosch
1990-08-08 22:37 ` Jim Marks
1990-08-09 12:45   ` Mike Wever
1990-08-09 15:59     ` Richard Pattis
1990-08-09  7:54 ` Rik Palo
1990-08-09 14:51 ` Allan Doyle
1990-08-09 16:15 ` Kurt Olender [this message]
1990-08-10 17:44   ` Alan Kaplan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox