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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,80a7e32bed946eb9 X-Google-Attributes: gid103376,public From: dewarr@my-dejanews.com Subject: Re: access_to_constant as subprogram paramater Date: 1998/09/19 Message-ID: <6u1b1h$f8d$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 392828874 References: <6u0pmf$rvk$1@nnrp1.dejanews.com> X-Http-Proxy: 1.0 x12.dejanews.com:80 (Squid/1.1.22) for client 205.232.38.10 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Sat Sep 19 22:25:53 1998 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.02 [en] (WinNT; U) Date: 1998-09-19T00:00:00+00:00 List-Id: In article <6u0pmf$rvk$1@nnrp1.dejanews.com>, nelson@blaze-net.com wrote: > > > 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 The real question here is why are you using an access parameter in any case. I think that access parameters tend to be very much overused. In your example, why on earth not just pass the string as an in parameter? -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum