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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,6609c40f81b32989 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!w42g2000yqm.googlegroups.com!not-for-mail From: Alex Mentis Newsgroups: comp.lang.ada Subject: Re: Why is Ada considered "too specialized" for scientific use Date: Thu, 8 Apr 2010 11:30:08 -0700 (PDT) Organization: http://groups.google.com Message-ID: <74613342-d58c-46e7-aa00-de9113b7f445@w42g2000yqm.googlegroups.com> References: NNTP-Posting-Host: 134.240.241.2 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1270751408 16960 127.0.0.1 (8 Apr 2010 18:30:08 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 8 Apr 2010 18:30:08 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: w42g2000yqm.googlegroups.com; posting-host=134.240.241.2; posting-account=CedHywoAAAAcVQwJt5x8TeyAwJA5ElaR User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:9939 Date: 2010-04-08T11:30:08-07:00 List-Id: On Apr 5, 4:28=A0pm, Warren wrote: > Nasser M. Abbasi expounded innews:hpddc6$csh$1@speranza.aioe.org: > > > Given this below > > > function Element (Container : Vector; > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Index =A0 =A0 : Index_Type) > > =A0 =A0return Element_Type; > > > Then to get the element at index 5, one needs to write something like > > Element(V,5). > > > Is there a way to redefine this so one need to only write V(5) ? > > You could use V.Element(5), but that doesn't really > shorten the notation. > > You could declare an internal function for that purpose, though > there are probably better solutions: > > procedure My_Proc(args...) is > > =A0 =A0package P is new Ada.Containers.Vector(...); > =A0 =A0V : P.Vector; > > =A0 =A0Function XV(X : Index_Type) returns Element_Type is > =A0 =A0begin > =A0 =A0 =A0 return V.Element(X); > =A0 =A0end; > begin > =A0 =A0... :=3D XV(5); > I guess you could also use a renames clause: package Vec is new Vectors (Index_Type =3D> Positive, Element_Type =3D> Integer); use Vec; function X_At (Container : Vector; Index : Positive) return Integer renames Vec.Element; but you lose the object.method notation: Put ( X_At (V, 5));