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: a07f3367d7,1449b098788729b8 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!j9g2000prh.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: prefix of dereference must be a name? Date: Mon, 3 Aug 2009 18:45:52 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1249350352 20267 127.0.0.1 (4 Aug 2009 01:45:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 4 Aug 2009 01:45:52 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j9g2000prh.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7555 Date: 2009-08-03T18:45:52-07:00 List-Id: On Jul 30, 12:09=A0am, Stephen Leake wrote: > I'd like to be able to do the following: > > type T is record ... end record; > type T_Access is access all T; > > function "+" (Left, Right in : ...) return T_Access; > > A : T_Access :=3D new T; > B : T_Access :=3D new T; > C : T_Access :=3D A + B; > > A.all :=3D (C + B).all; > > but GNAT complains that "prefix for selection is not a name", pointing > to (C + B).all. > > So then I tried: > > function "-" (Token : in T_Access) return T_Access > is begin > =A0 =A0 return Token; > end; > > A.all :=3D -(C + B).all; > > and got the same error. Finally I tried: > > function Copy (Token : in T_Access) return T_Access > is begin > =A0 =A0 return Token; > end; > > A.all :=3D Copy (C + B).all; > > And the compiler was happy. > > What's the rationale for this? > > I assume one issue here is that "-" might be an intrinsic, but since > the type involved is not a numeric type, I don't see how that could be > a problem. > > Similarly for ().all; when could that be a problem? You should look over AI05-0003. I think there's a fair amount of sympathy for your position; I agree that it would have been better to have less distinction between "names" and "expressions", but the problem just never made it high enough on the priority list. It's simple to say "You should be able to use an expression with an operator wherever you could use the equivalent function call", but not at all simple to change the language rules consistently and make sure the change doesn't cause any other problems, and probably not at all simple for all the compiler vendors to make the necessary changes. AI05-0003 will fix one related issue, I think, to allow qualified expressions [Type'(Function_Call(...))] to be used where they currently can't. I felt this one was important, because using qualified expressions is sometimes the only reasonable way to eliminate ambiguities in overloading cases---or at least the only non- clunky way. In your examples, you *could* always replace (A+B) with "+"(A,B) to get around the problem, so it's not as important to have this fixed, and a decision has to be made about whether it's worth the effort. But I agree that it would have been nice if the language had been designed "right" at the beginning. -- Adam