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,672b169dc220673a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.205.134.138 with SMTP id ic10mr2494750bkc.8.1337616061991; Mon, 21 May 2012 09:01:01 -0700 (PDT) Path: e27ni33319bkw.0!nntp.google.com!news2.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: Mon, 21 May 2012 08:57:18 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <10616734.43.1337286031745.JavaMail.geo-discussion-forums@vbjy7> <70510fa1-e554-44a7-9364-e745674c1bda@googlegroups.com> <28845c63-b06c-4ac2-b5d5-e408c0ff4b7f@googlegroups.com> <70817af5-96c3-4ca7-8d1c-b7635452bf4c@googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1337615961 28353 127.0.0.1 (21 May 2012 15:59:21 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 21 May 2012 15:59:21 +0000 (UTC) In-Reply-To: <70817af5-96c3-4ca7-8d1c-b7635452bf4c@googlegroups.com> 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 Content-Transfer-Encoding: quoted-printable Date: 2012-05-21T08:57:18-07:00 List-Id: On Saturday, May 19, 2012 2:03:56 AM UTC-7, marius63 wrote: > > > V : My_Vectors.Vector :=3D Element1 + Element2 + Element3; > > > > > > A bit less inelegant. > > > > > > /* But more than parenthesis or T'(...) in my view. */ > >=20 > > You mean more inelegant, or more elegant? >=20 > Oops, sorry, I mean more elegant, i.e. I find >=20 > Element1 + Element2 + Element3 >=20 > more elegant than >=20 > (T'(Element1) & T'(Element2)) & T'(Element3) >=20 > or variations thereof. (Textual elegancy. I agree the latter form has mor= e semantic rigour =3D abstract elegancy.) FYI, the last expression won't work the way you wrote it. If Element1 is a= n object declared with type T, then saying T'(Element1) won't gain you anyt= hing (other than possibly clarifying things for a reader), since the compil= er already knows that Element1 has type T. The & operation needs to be enc= losed in the parentheses in T'(...) to make a difference. That's what tell= s the compiler that when there are competing possibilities for &, to use th= e one that returns T. As for which one is more elegant: this is a matter of opinion, but personal= ly, if you have a small (maybe 15 lines) subprogram or block that uses this= expression, and the "+" rename is declared locally within that subprogram = or block, it wouldn't be hard to figure out. But if I'm trying to read you= r code, and I see this expression and start having to hunt for what "+" mea= ns, the result will probably include a set of curse words that are not very= elegant. So in that sense, using the "+" rename reduces overall elegance.= I'm sure you already realize this, but for others' benefit: elegance is a= worthwhile goal only if it enhances readability by removing clutter withou= t doing anything else that makes it harder to understand. Otherwise, the o= nly way elegance is useful is if your goal is to hang a framed listing of y= our program on the wall, rather than to run it. -- Adam=20