comp.lang.ada
 help / color / mirror / Atom feed
* access_to_constant as subprogram paramater
@ 1998-09-19  0:00 nelson
  1998-09-19  0:00 ` dewarr
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: nelson @ 1998-09-19  0:00 UTC (permalink / raw)




Why does the language disallow an access_to_constant as a parameter
to a subprogram?

For example:

--
-- Example illustrating desire to pass access_to_constant to a procedure.
-- Refer to RM 3.10(12) and 6.1.
--
procedure Access_Parameter is

   PathName : aliased constant String := "/a/b/c.adb";
      -- Declared as constant in order to produce compilation error


   procedure Parse (Input : access String) is
--
-- Would like to declare this:
--    procedure Parse (Input : access constant String) is
-- as Parse never modifies the input string
--
   begin
      null;  -- Parse a pathname string into components
   end Parse;

begin
   Parse(PathName'Access);  -- line 22
end Access_Parameter;



for which gnat produces:


cd /usr/nelson/example/
gnatmake -c access_parameter.adb
gcc -c access_parameter.adb
access_parameter.adb:22:10: access-to-variable designates constant
gnatmake: "access_parameter.adb" compilation error

Compilation exited abnormally with code 2 at Sat Sep 19 13:23:25

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1998-09-20  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-09-19  0:00 access_to_constant as subprogram paramater nelson
1998-09-19  0:00 ` dewarr
1998-09-19  0:00 ` Tucker Taft
1998-09-20  0:00   ` dewarr
1998-09-19  0:00 ` David C. Hoos, Sr

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