From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=BAYES_00,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: Ok - WHAT are those "Maps.Identity" things ??? Date: Fri, 7 Jan 2022 10:49:54 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 7 Jan 2022 09:49:55 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="05fd67cb75ba5878beecc9e388dfee63"; logging-data="25593"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3OrS4HPBixSKnXG8JqEpwFP8dM+JzXUs=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Cancel-Lock: sha1:SWmi1UxdVHUD0Ny6c1lGhd8MxJA= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63353 List-Id: On 2022-01-07 03:41, 1.AAC0832 wrote: >> >> and lists 6 functions named Index (and 2 for Index_Non_Blank). Of these I >> mostly use the one at paragraph 9: >> >> 9  function Index (Source   : in String; >>                     Pattern  : in String; >>                     Going    : in Direction := Forward; >>                     Mapping  : in Maps.Character_Mapping >>                                  := Maps.Identity) >>        return Natural; >> >> with the defaults for the last 2 parameters. Occasionally I've used a Going => >> Backward, > > >   I'm using unbounded strings and there's a version in >   that library with the same params - but Gnat seems >   to DEMAND the last two params. Might try the fixed >   library by casting my unbounded to string ... I missed that detail in your original msg. Ada.Strings.Unbounded (ARM A.4.5) has similar Index functions, but note that Source is Unbounded_String and Pattern is String. As Brukardt said, without more detail we can't tell what is really going on, but my experience is that GNAT will not require defaulted parameters. More likely GNAT is trying to do overload resolution when there is no visible subprogram that matches the parameters you are passing; the resulting error msgs are not clear. Experienced Ada users find that Unbounded_String is needed a lot less than is expected by people coming from languages where strings are magic. Unless you need data structures with varying-length strings, you don't often need them. >   I've been programming since a tad before the dawn of the >   Apples and Commodores - punch cards and serial terminals >   wired to the mini-mainframe, FORTRAN, COBOL, that horrible >   stuff. For some reason I just can't grock a lot of the Ada >   docs. Lots and lots of DESCRIPTIONS about how to do things >   but a "picture" is worth a thousand words ... I also started out with FORTRAN-66 on punched cards, but my experience is the opposite: Ada (without the features that were mistakes) supports very well the way I engineer S/W. -- Jeff Carter "Hello! Smelly English K...niggets." Monty Python & the Holy Grail 08