home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / ada / 3816 < prev    next >
Encoding:
Internet Message Format  |  1992-12-24  |  2.3 KB

  1. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!Sirius.dfn.de!chx400!sicsun!disuns2!lglsun!nebbe
  2. From: nebbe@lglsun.epfl.ch (Robb Nebbe)
  3. Newsgroups: comp.lang.ada
  4. Subject: Re: Visibility
  5. Message-ID: <1992Dec24.124852@lglsun.epfl.ch>
  6. Date: 24 Dec 92 11:48:52 GMT
  7. References: <1992Dec23.233519.21523@netfs.dnd.ca> <1992Dec24.021655.22555@beaver.cs.washington.edu>
  8. Sender: news@disuns2.epfl.ch
  9. Organization: Ecole Polytechnique Federale de Lausanne
  10. Lines: 53
  11. Nntp-Posting-Host: lglsun5.epfl.ch
  12.  
  13. In article <1992Dec24.021655.22555@beaver.cs.washington.edu>, pattis@cs.washington.edu (Richard Pattis) writes:
  14. |> In article <1992Dec23.233519.21523@netfs.dnd.ca> BERRYMAN@orca.drep.dnd.ca (DON BERRYMAN) writes:
  15. |> >
  16. |> >
  17. |> >I have a quesiton on Visiblity. The following Ada code
  18. |> >generates the following error.
  19. |> >
  20. |> >
  21. |> >     package datatypes is
  22. |> >         subtype widget is integer;
  23. |> >     end datatypes;
  24. |> >
  25. |> >     with datatypes;
  26. |> >     package testvisibility is
  27. |> >         function widget (a: integer) return datatypes.widget;
  28. |> >     end testvisibility;
  29. |> >
  30. |> 
  31. |> The LRM says in 8.3(16) "every declaration with the same designator" is
  32. |> hidden. And designators are only identifiers or operator symbols. So it looks
  33. |> like your designator widget, even when declared in another package and
  34. |> selected, is still hidden.  There are two notes on this, but both involve
  35. |> generics
  36. |> 
  37. |> Now, can anyone say why this interpretation "is a good thing".
  38. |> 
  39. |> Rich Pattis
  40. |> 
  41.  
  42. I think the rule is intended as the simplest way of preventing someone
  43. from writing the following:
  44.  
  45. function widget (A : integer := widget) return integer;
  46.  
  47. This prevents the compiler from having to figure out what the designator
  48. corresponds to and whether or not it should be legal. The above code
  49. obviously won't work but how about:
  50.  
  51. function widget (A : integer := widget(1)) return integer;
  52.  
  53. I think they wanted to avoid all these legalistic problems and so they
  54. just came up with the simplest rule possible that eliminated the problem.
  55. If people think that Ada is hairy now they should just imagine if it had
  56. rules like:
  57.  
  58. Within the specification of a function, every declaration with the same 
  59. designator as the function that is found as a default value in the
  60. parameter list is hidden; ...
  61.  
  62. I would think rules like this would be a compiler writers nightmare.
  63.  
  64. Robb Nebbe
  65. nebbe@lglsun.epfl.ch
  66.