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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8f802583e5c84fa X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: String filtering Date: 03 Oct 2005 13:59:56 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1KednYZNMNxP8NzeRVn-3A@comcast.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1128362396 24878 192.74.137.71 (3 Oct 2005 17:59:56 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 3 Oct 2005 17:59:56 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:5357 Date: 2005-10-03T13:59:56-04:00 List-Id: tmoran@acm.org writes: > > function Intern(Table: in out Symbol_Table; -- illegal! > > X: String) return Symbol; > >... > > Tok: Token := Get_Token(Stream); [-- illegal] > >... > > function Get_Line(S: in out Stream) return String; -- illegal! > Isn't that why > function S'Input(Stream : access Ada.Streams.Root_Stream_Type'Class) > return T; > takes an access parameter? Yes. > Is it very difficult to do the same with Intern or Get_Token or Get_Line? It's a pain to have to declare things 'aliased' all over the place. It's a "cry wolf" thing -- 'aliased' should mean I'm making possibly-permanent pointers to that thing. But here, we don't want a pointer (except as a temporary by-reference parameter). "aliased Blah'Class" means "Warning Will Robinson: this procedure might save the pointer in a global data structure." But that's not what S'Input is doing. And there's some run-time overhead for access parameters -- they carry run-time accessibility-level info with them. Furthermore, there's (annoyingly) no way to declare a formal parameter aliased. So you use 'access' where 'in out' should suffice, or you declared tagged types that have no need for a tag. Yes, there are workarounds for the lack of [in] out params on functions -- but they have global consequences on your code. - Bob