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: 103376,6609c40f81b32989 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!feeder.news-service.com!188.40.43.213.MISMATCH!feeder.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Warren Newsgroups: comp.lang.ada Subject: Re: Why is Ada considered "too specialized" for scientific use Date: Mon, 5 Apr 2010 20:28:24 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: Injection-Date: Mon, 5 Apr 2010 20:28:24 +0000 (UTC) Injection-Info: feeder.eternal-september.org; posting-host="9f8M0iN5t54V+4DF/iqO8g"; logging-data="16392"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19VRX/A5d96ObMHH66JlNKRApyX9jrVa1Q=" User-Agent: Xnews/5.04.25 X-Face: &6@]C2>ZS=NM|HE-^zWuryN#Z/2_.s9E|G&~DRi|sav9{E}XQJb*\_>=a5"q]\%A;5}LKP][1mA{gZ,Q!j Cancel-Lock: sha1:VJTEmSegdi1uaaw8vdUwS3hBdcI= Xref: g2news2.google.com comp.lang.ada:10854 Date: 2010-04-05T20:28:24+00:00 List-Id: Nasser M. Abbasi expounded in news:hpddc6$csh$1@speranza.aioe.org: >> I am making big use of these containers in the rewrite of >> my basic interpreter project. > > > I looked at the Ada 2005 LRM, Containers.Vectors for example, and And > I have small question > > http://www.adaic.org/standards/05rm/html/RM-A-18-2.html > > Given this below > > function Element (Container : Vector; > Index : Index_Type) > return 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 package P is new Ada.Containers.Vector(...); V : P.Vector; Function XV(X : Index_Type) returns Element_Type is begin return V.Element(X); end; begin ... := XV(5); Note however (as I found out, snickers), you can't use the V.Element() notation when the input value is a cursor. That kept tripping me up until I clued in-- the cursor specifies both the container and position internally. So you must use Element(Csr) form of the call instead, for cursor values. > because If I have large equations, it is more clear to write V(i) than > Element(V,i) everywhere? Did you find this "longer" syntax an issue > for you? Not really, because when you deal with several containers (Maps mostly in my case), I tend to spell out the full package heirarchy anyway for clarity and to avoid hiding caused by "use". One thing I did do however, was create a SimpMap package that took care of all of the compare function definitions for me. I got real tired of redeclaring equality functions for every new integer/modular type involved. > I have not used Containers before. But the list of functions looks > impressive. > > ps. is your interpreter project somewhere on the net to look at? > > thanks, > --Nasser My Ada rewrite is still in the early stages, so it is not up on SourceForge yet. If you want to experiment with the C version, or look at the documentation, you can visit: https://sourceforge.net/projects/bdbbasic or for language and other documentation: https://sourceforge.net/apps/mediawiki/bdbbasic/index.php?title=Main_Page But if you email me directly, I can also send you the tar-balled Ada version of the project. You'll see a lot of container examples in it, which might be useful. Warren