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,672b169dc220673a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.195.131 with SMTP id ie3mr11628533pbc.8.1337297629643; Thu, 17 May 2012 16:33:49 -0700 (PDT) Path: pr3ni11339pbb.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Vector (container) initialization: the schizophrenic ampersand Date: Thu, 17 May 2012 16:33:48 -0700 (PDT) Organization: http://groups.google.com Message-ID: <70510fa1-e554-44a7-9364-e745674c1bda@googlegroups.com> References: <10616734.43.1337286031745.JavaMail.geo-discussion-forums@vbjy7> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1337297629 11654 127.0.0.1 (17 May 2012 23:33:49 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 17 May 2012 23:33:49 +0000 (UTC) In-Reply-To: <10616734.43.1337286031745.JavaMail.geo-discussion-forums@vbjy7> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-05-17T16:33:48-07:00 List-Id: On Thursday, May 17, 2012 1:20:31 PM UTC-7, marius63 wrote: > Shouldn't this be the right idiom to initialize a vector (container) with literals: > > use My_Vectors; > V : My_Vectors.Vector := Element1 & Element2 & Element3; > > Looks nice, but does not compile (with GNAT), because the compiler cannot make a decision on which "&" function to use where. Is there a way to give precedence to one of the "&" functions? Or some other nice solution? Thanks. > > /* > My current solution is to rename one of the functions: > > use My_Vectors; > > function "+" (L : My_Vectors.Vector; R : My_Element_Type) > renames My_Vectors."&"; > > V : My_Vectors.Vector := Element1 & Element2 + Element3; > > Not elegant at all. > */ It compiled for me the first time I tried it, so I think we need more information, in particular what your element type is. A complete example that compiles except for that error would be helpful. Parentheses won't help. The operator precedence rules mean that the expression is always interpreted as (Element1 & Element2) & Element3 regardless of what functions the operators refer to. If your element type is some sort of array, then there could be a conflict with the built-in array concatenation operator. The solution might be V : My_Vectors.Vector := My_Vectors.Vector'(Element1 & Element2) & Element3; to make it clear that the first "&" must be the one that returns a Vector. -- Adam