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: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: access_to_constant as subprogram paramater Date: 1998/09/19 Message-ID: #1/1 X-Deja-AN: 392792551 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <6u0pmf$rvk$1@nnrp1.dejanews.com> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1998-09-19T00:00:00+00:00 List-Id: nelson@blaze-net.com wrote: : Why does the language disallow an access_to_constant as a parameter : to a subprogram? At the time of the design, we didn't have a compelling-enough reason to include this capability. Personally, I was a little concerned that using "access constant" for access-to-constant parameters, but simply "access" (instead of "access all") for access-to-variable parameters would also confuse people. In retrospect, I wish we had included the access-to-constant parameters, but it doesn't seem like a very big deal either way. In any case, you can just use a named access-to-constant type in many cases, or even simpler, a plain old "IN" parameter. : 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; What's wrong with "Input : in String"? That seems by far the simpler approach in a case like this, and no need to use that gnarly "'Access" at all. -- -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA An AverStar Company