home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!paladin.american.edu!darwin.sura.net!Sirius.dfn.de!chx400!sicsun!disuns2!lglsun!nebbe
- From: nebbe@lglsun.epfl.ch (Robb Nebbe)
- Newsgroups: comp.lang.ada
- Subject: Re: Visibility
- Message-ID: <1992Dec24.124852@lglsun.epfl.ch>
- Date: 24 Dec 92 11:48:52 GMT
- References: <1992Dec23.233519.21523@netfs.dnd.ca> <1992Dec24.021655.22555@beaver.cs.washington.edu>
- Sender: news@disuns2.epfl.ch
- Organization: Ecole Polytechnique Federale de Lausanne
- Lines: 53
- Nntp-Posting-Host: lglsun5.epfl.ch
-
- In article <1992Dec24.021655.22555@beaver.cs.washington.edu>, pattis@cs.washington.edu (Richard Pattis) writes:
- |> In article <1992Dec23.233519.21523@netfs.dnd.ca> BERRYMAN@orca.drep.dnd.ca (DON BERRYMAN) writes:
- |> >
- |> >
- |> >I have a quesiton on Visiblity. The following Ada code
- |> >generates the following error.
- |> >
- |> >
- |> > package datatypes is
- |> > subtype widget is integer;
- |> > end datatypes;
- |> >
- |> > with datatypes;
- |> > package testvisibility is
- |> > function widget (a: integer) return datatypes.widget;
- |> > end testvisibility;
- |> >
- |>
- |> The LRM says in 8.3(16) "every declaration with the same designator" is
- |> hidden. And designators are only identifiers or operator symbols. So it looks
- |> like your designator widget, even when declared in another package and
- |> selected, is still hidden. There are two notes on this, but both involve
- |> generics
- |>
- |> Now, can anyone say why this interpretation "is a good thing".
- |>
- |> Rich Pattis
- |>
-
- I think the rule is intended as the simplest way of preventing someone
- from writing the following:
-
- function widget (A : integer := widget) return integer;
-
- This prevents the compiler from having to figure out what the designator
- corresponds to and whether or not it should be legal. The above code
- obviously won't work but how about:
-
- function widget (A : integer := widget(1)) return integer;
-
- I think they wanted to avoid all these legalistic problems and so they
- just came up with the simplest rule possible that eliminated the problem.
- If people think that Ada is hairy now they should just imagine if it had
- rules like:
-
- Within the specification of a function, every declaration with the same
- designator as the function that is found as a default value in the
- parameter list is hidden; ...
-
- I would think rules like this would be a compiler writers nightmare.
-
- Robb Nebbe
- nebbe@lglsun.epfl.ch
-