* Ok - WHAT are those "Maps.Identity" things ???
@ 2022-01-05 0:54 1.AAC0831
2022-01-05 5:49 ` Rod Kay
2022-01-05 13:01 ` Jeffrey R.Carter
0 siblings, 2 replies; 18+ messages in thread
From: 1.AAC0831 @ 2022-01-05 0:54 UTC (permalink / raw)
I'll try to squeeze in between the "Hot Lezbo Action" spam ...
Ok ... ADA online documentation is POOR. Lots of
definitions, often NO practical examples of even
the simplest things. You'd expect more for an
"official DOD" language.
Problem : I want to find out if/where a substring
is in another string (lets assume unbounded strings).
The docs say to use Index(source,substr,<something>,<something-identity>)
Well, I can guess what the first two are. The third probably
is "forward" or maybe '1' for "start at first'. However all
examples of Index have some kind of mapping param for #4
and I've used every search engine and CANNOT figure out what
goes in there.
Sure, I can take progressive slices of the source and compare
them to the substring - the HARD old-fashioned way - but so
long as there's a library function I'd like to know how
to USE the thing. Not a single comprehensible example in
the whole world. There are a lot of string-related functions
that look useful, and most use this mystery 'mapping' thing.
Oh yea, just doing x:=Index(src,sub) generates a "no
candidates" error in Gnat.
I just finished a sort of managed list thing for text
files that sort of does what FPC tStringList can do.
Linked-list of named stringlists and vital params and
access (pointers) to another linked list that actually
holds the text strings. Advantage ... you don't have to
know how many lines are in the text file - could be
one, could be a million, so you don't have to guess
about the size of the holding array. If you need to
use several named lists just add something to that name
and it sets itself up.
All that works fine. The very last thing I wanted to
add was a "is substring in string" function - might
return a boolean, but I might cheat and return a real
with the listindex .point. position-in-str sort of format.
Thought I should learn some Ada "just because". It's a
very picky language. I suppose that makes it "safer"
but come ON now ! I want to escape to good old 'C'
and Pascal now (actually I've changed most of my Python
apps over to FPC/Delphi of late because interpreted
languages are awkward unless you use Cython or something
to turn 'em into executables. Alas no matter what you
do they are STILL kinda hostage to the exact version
of Python on the machine ............
Anyway, yes, some people ARE still interested in some
of these "old" computer languages. I even wrote a little
FORTRAN pgm, first I'd done in like 30+ years. The newer
versions ARE easier than the old "this goes in THIS
column, that goes in THAT column" :-) Algol68 is
underdocumented (and kinda weird) and the current GM2
modula-2 in the linux repos doesn't seem to work as
advertized (haven't quite got the modula-3 compiler
up and going yet, but I WILL).
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-05 0:54 Ok - WHAT are those "Maps.Identity" things ??? 1.AAC0831
@ 2022-01-05 5:49 ` Rod Kay
2022-01-07 2:31 ` 1.AAC0832
2022-01-05 13:01 ` Jeffrey R.Carter
1 sibling, 1 reply; 18+ messages in thread
From: Rod Kay @ 2022-01-05 5:49 UTC (permalink / raw)
On 5/1/22 11:54 am, 1.AAC0831 wrote:
>
> Ok ... ADA online documentation is POOR. Lots of
> definitions, often NO practical examples of even
> the simplest things. You'd expect more for an
> "official DOD" language.
>
With a duckduckgo search on "ada string index", the first hit is ...
https://learn.adacore.com/courses/intro-to-ada/chapters/standard_library_strings.html
... which provides a simple example of the 'Index' function.
> Problem : I want to find out if/where a substring
> is in another string (lets assume unbounded strings).
>
> The docs say to use Index(source,substr,<something>,<something-identity>)
>
> Well, I can guess what the first two are. The third probably
> is "forward" or maybe '1' for "start at first'. However all
> examples of Index have some kind of mapping param for #4
> and I've used every search engine and CANNOT figure out what
> goes in there.
https://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-4-2.html
https://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-4-3.html
In many/most cases, the default parameters for 'Mapping' are fine.
> All that works fine. The very last thing I wanted to
> add was a "is substring in string" function - might
> return a boolean, but I might cheat and return a real
> with the listindex .point. position-in-str sort of format.
>
function Contains (Source : in String; Pattern : in String)
return Boolean
is
use Ada.Strings.Fixed;
begin
return Index (Source, Pattern) /= 0;
end Contains;
In summary, Ada is one of the the best documented languages in
existence. Consider the excellent 'Language Reference Manual', the 'Ada
Rationale's and the 'Ada Quality and Style Guide's.
Furthermore the resources at 'https://learn.adacore.com' and
'https://www.adacore.com/gems' provide many examples of best practices
in specific areas of interest.
Finally, forums such as 'comp.lang.ada' and the '#ada' irc channel
on the 'irc.libera.chat' server are great places to quickly find answers.
Regards.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-05 0:54 Ok - WHAT are those "Maps.Identity" things ??? 1.AAC0831
2022-01-05 5:49 ` Rod Kay
@ 2022-01-05 13:01 ` Jeffrey R.Carter
2022-01-07 2:41 ` 1.AAC0832
1 sibling, 1 reply; 18+ messages in thread
From: Jeffrey R.Carter @ 2022-01-05 13:01 UTC (permalink / raw)
On 2022-01-05 01:54, 1.AAC0831 wrote:
>
> The docs say to use Index(source,substr,<something>,<something-identity>)
I don't know what "docs" you mean. Anyone using Ada should be familiar with its
standard library, which is documented in Annex A of the ARM at
http://www.ada-auth.org/standards/aarm12_w_tc1/html/AA-A.html
(I provide the link to the AARM as the annotations are sometimes useful.)
The documentation for Ada.Strings.Fixed is at
http://www.ada-auth.org/standards/aarm12_w_tc1/html/AA-A-4-3.html
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,
The Mapping/Test parameters are for specialized needs, such as case-insensitive
matching or folding accented characters together, and the default will work if
you don't need anything like that.
--
Jeff Carter
"When and now is this guitar piece from Stottlemeyer?
Yes, it's with Mr. Dog in Gertrude's pinball forest."
The World's Funniest Joke
133
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-05 5:49 ` Rod Kay
@ 2022-01-07 2:31 ` 1.AAC0832
2022-01-07 3:39 ` Gautier write-only address
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: 1.AAC0832 @ 2022-01-07 2:31 UTC (permalink / raw)
On 1/5/22 12:49 AM, Rod Kay wrote:
> On 5/1/22 11:54 am, 1.AAC0831 wrote:
>>
>> Ok ... ADA online documentation is POOR. Lots of
>> definitions, often NO practical examples of even
>> the simplest things. You'd expect more for an
>> "official DOD" language.
>>
>
> With a duckduckgo search on "ada string index", the first hit is ...
>
> https://learn.adacore.com/courses/intro-to-ada/chapters/standard_library_strings.html
Gnat wants FOUR params ... and it's the last "map" related
one that's most mysterious. I'd also seen examples using
only TWO params ... but the compiler balks.
In any case :
Idx := Index
(Source => S,
Pattern => P,
From => Idx + 1);
won't compile no matter what you put in "from".
Oh well, I actually wrote my own. It works just fine
and I was able to finish what I had in mind. Progressive
slices of the source string compared against the "needle"
string with "unbounded_slice" as the cutter-upper. DID
do a quick pre-scan to see if at least the first char of
the needle appears in the source and where. We start
slicing from there, which saves iterations.
> ... which provides a simple example of the 'Index' function.
>
>
>> Problem : I want to find out if/where a substring
>> is in another string (lets assume unbounded strings).
>>
>> The docs say to use Index(source,substr,<something>,<something-identity>)
>>
>> Well, I can guess what the first two are. The third probably
>> is "forward" or maybe '1' for "start at first'. However all
>> examples of Index have some kind of mapping param for #4
>> and I've used every search engine and CANNOT figure out what
>> goes in there.
>
>
> https://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-4-2.html
>
>
> https://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-4-3.html
>
>
> In many/most cases, the default parameters for 'Mapping' are fine.
>
>
>> All that works fine. The very last thing I wanted to
>> add was a "is substring in string" function - might
>> return a boolean, but I might cheat and return a real
>> with the listindex .point. position-in-str sort of format.
>>
>
> function Contains (Source : in String; Pattern : in String)
> return Boolean
> is
> use Ada.Strings.Fixed;
> begin
> return Index (Source, Pattern) /= 0;
> end Contains;>
None of my strings are fixed. Those get "stuck" in
size the first time you assign them and are mostly
useless IMHO. Tried to use the library with "to_string()"
but still no joy.
Anyway, thanks for the input - I'll try a few suggested
variations from your docs. For now though it's back to
Lazarus/FPC for a different practical project - the
kind they pay you for :-)
I'm not gonna buy $100 books for a language I was only
curious about. Adaic seems to have some fair online
info though.
> In summary, Ada is one of the the best documented languages in
> existence. Consider the 'Language Reference Manual', the 'Ada
> Rationale's and the 'Ada Quality and Style Guide's.
>
> Furthermore the resources at 'https://learn.adacore.com' and
> 'https://www.adacore.com/gems' provide many examples of best practices
> in specific areas of interest.
>
> Finally, forums such as 'comp.lang.ada' and the '#ada' irc channel
> on the 'irc.libera.chat' server are great places to quickly find answers.
>
>
> Regards.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-05 13:01 ` Jeffrey R.Carter
@ 2022-01-07 2:41 ` 1.AAC0832
2022-01-07 9:49 ` Jeffrey R.Carter
0 siblings, 1 reply; 18+ messages in thread
From: 1.AAC0832 @ 2022-01-07 2:41 UTC (permalink / raw)
On 1/5/22 8:01 AM, Jeffrey R.Carter wrote:
> On 2022-01-05 01:54, 1.AAC0831 wrote:
>>
>> The docs say to use Index(source,substr,<something>,<something-identity>)
>
> I don't know what "docs" you mean. Anyone using Ada should be familiar
> with its standard library, which is documented in Annex A of the ARM at
>
> http://www.ada-auth.org/standards/aarm12_w_tc1/html/AA-A.html
>
> (I provide the link to the AARM as the annotations are sometimes useful.)
>
> The documentation for Ada.Strings.Fixed is at
>
> http://www.ada-auth.org/standards/aarm12_w_tc1/html/AA-A-4-3.html
>
> 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 ...
Anyway, in frustration I just wrote my own. Works good
and I was able to finish what I wanted to do.
> The Mapping/Test parameters are for specialized needs, such as
> case-insensitive matching or folding accented characters together, and
> the default will work if you don't need anything like that.
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 ...
But I really really like Pascal better.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-07 2:31 ` 1.AAC0832
@ 2022-01-07 3:39 ` Gautier write-only address
2022-01-07 4:14 ` Randy Brukardt
2022-01-07 11:48 ` G.B.
2 siblings, 0 replies; 18+ messages in thread
From: Gautier write-only address @ 2022-01-07 3:39 UTC (permalink / raw)
> > https://learn.adacore.com/courses/intro-to-ada/chapters/standard_library_strings.html
> Gnat wants FOUR params ... and it's the last "map" related
> one that's most mysterious. I'd also seen examples using
> only TWO params ... but the compiler balks.
>
> In any case :
> Idx := Index
> (Source => S,
> Pattern => P,
> From => Idx + 1);
>
> won't compile no matter what you put in "from".
Uh? Do you see the big "Run" button on the Web site mentioned above? Click on it!
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-07 2:31 ` 1.AAC0832
2022-01-07 3:39 ` Gautier write-only address
@ 2022-01-07 4:14 ` Randy Brukardt
2022-01-10 5:13 ` 1.AAC0832
2022-01-07 11:48 ` G.B.
2 siblings, 1 reply; 18+ messages in thread
From: Randy Brukardt @ 2022-01-07 4:14 UTC (permalink / raw)
"1.AAC0832" <z24ba7.net> wrote in message
news:AOmdnX_3T5ObO0r8nZ2dnUU7-IHNnZ2d@earthlink.com...
...
> Gnat wants FOUR params ... and it's the last "map" related
> one that's most mysterious. I'd also seen examples using
> only TWO params ... but the compiler balks.
>
> In any case :
> Idx := Index
> (Source => S,
> Pattern => P,
> From => Idx + 1);
>
> won't compile no matter what you put in "from".
I use this sort of thing all the time (especially in the Trash-Finder spam
filter), and it works fine. You never have to give the 4th parameter in
these routines as they have a defined default which allows you to omit them.
So it's highly likely that you've done something else wrong which is why
nothing you try works.
But you've given so little detail about your program, it's impossible to
help. Ada resolution can be finiky, especially when a routine is overloaded
as Index is, and that is also the case where it is difficult/impossible for
a compiler to give an understandable error message. To get useful help
around here, you need to provide a complete example (including all of the
declarations and use clauses and with clauses). Otherwise, it just ends up
being griping and people will tune you out.
For instance, in the above, I have no idea what types S, P, and Idx have --
and that matters a lot -- Ada is a very strongly typed language.
Randy.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-07 2:41 ` 1.AAC0832
@ 2022-01-07 9:49 ` Jeffrey R.Carter
2022-01-10 4:46 ` 1.AAC0832
0 siblings, 1 reply; 18+ messages in thread
From: Jeffrey R.Carter @ 2022-01-07 9:49 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-07 2:31 ` 1.AAC0832
2022-01-07 3:39 ` Gautier write-only address
2022-01-07 4:14 ` Randy Brukardt
@ 2022-01-07 11:48 ` G.B.
2022-01-10 4:49 ` 1.AAC0832
2 siblings, 1 reply; 18+ messages in thread
From: G.B. @ 2022-01-07 11:48 UTC (permalink / raw)
On 07.01.22 03:31, 1.AAC0832 wrote:
> Gnat wants FOUR params ... and it's the last "map" related
> one that's most mysterious. I'd also seen examples using
> only TWO params ... but the compiler balks.
>
> In any case :
> Idx := Index
> (Source => S,
> Pattern => P,
> From => Idx + 1);
>
> won't compile no matter what you put in "from".
In case you use the opaque type Unbounded_String everywhere,
and then the Index function, it is documented to want a String,
not an Unbounded_String for the Pattern. So, if that's the case,
get a normal (fixes size array) String from an Unbounded_String
object first.
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
function pos2 (hay_stack : Unbounded_String; needle : Unbounded_String)
return Natural
is
result : Natural;
begin
result := Index (Source => hay_stack,
Pattern => To_String(needle),
From => 2);
return result;
end pos2;
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-07 9:49 ` Jeffrey R.Carter
@ 2022-01-10 4:46 ` 1.AAC0832
2022-01-10 15:05 ` Simon Wright
0 siblings, 1 reply; 18+ messages in thread
From: 1.AAC0832 @ 2022-01-10 4:46 UTC (permalink / raw)
On 1/7/22 4:49 AM, Jeffrey R.Carter wrote:
> 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.
Hmmmm .... I *may* be using another unbounded for the "needle".
I'll have to check that. Maybe it's not upset about the last
two params, but the unbounded needle !
DID write my own function to accomplish the task - one that
uses unbounded for everything. Works fine. But if a standard
library function can do it ...
> 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.
Having to re-DECLARE fixed strings over and over, and
deeper and deeper if you need nested logic, is just
unbearable. It's UGLY.
But I wanted to learn a little Ada ...
>> 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.
Different people find different languages just click
with the way they think. If it's Ada for you, fine,
you should be able to accomplish most anything you
need to do. 'C' and Pascal are more in my way of
thinking. Did learn Python quite well - but I don't
use classes.
But if you want a buzz ... assembler -) Way back in
at the dawn of the home computer era I knew this guy,
classic so-smart-he-was-crazy type, who made a living
re-writing commercial video game cartridges. He
wrote everything on a PET ML monitor - in BINARY -
before burning it to cartridges. Said it gave him a buzz.
I'll do asssembler for PICs/8051s/etc but not much binary
unless it's to set flag groups.
I think the human brain really can't handle anything much
above the IQ-160 level. After that, one gain requires the
loss of some other function. The aforementioned guy, I'd
put him right around IQ-200, and he was NOT "right".
In any case, thanks for the input. This group is so packed
with spam that I wondered if anybody real still used it.
I consider Ada "important" enough to know something about.
Heh ... though my new Pascal project - have been using
double-quoted string constants and "&" instead of "+"
rather often :-)
Wanted to do Modula-2/3 experiments - but GNU GM2 isn't
right on the current distros and throws all kinds of
errors even with "Hello World". Found an M3 compiler
but it's going to need some tuning-in.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-07 11:48 ` G.B.
@ 2022-01-10 4:49 ` 1.AAC0832
0 siblings, 0 replies; 18+ messages in thread
From: 1.AAC0832 @ 2022-01-10 4:49 UTC (permalink / raw)
On 1/7/22 6:48 AM, G.B. wrote:
> On 07.01.22 03:31, 1.AAC0832 wrote:
>
>> Gnat wants FOUR params ... and it's the last "map" related
>> one that's most mysterious. I'd also seen examples using
>> only TWO params ... but the compiler balks.
>>
>> In any case :
>> Idx := Index
>> (Source => S,
>> Pattern => P,
>> From => Idx + 1);
>>
>> won't compile no matter what you put in "from".
>
> In case you use the opaque type Unbounded_String everywhere,
> and then the Index function, it is documented to want a String,
> not an Unbounded_String for the Pattern. So, if that's the case,
> get a normal (fixes size array) String from an Unbounded_String
> object first.
>
> with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
>
> function pos2 (hay_stack : Unbounded_String; needle : Unbounded_String)
> return Natural
> is
> result : Natural;
> begin
> result := Index (Source => hay_stack,
> Pattern => To_String(needle),
> From => 2);
> return result;
> end pos2;
I'll try it as writ.
Someone else said the "needle" is a straight-up STRING
however ... and I'd been sending an unbounded.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-07 4:14 ` Randy Brukardt
@ 2022-01-10 5:13 ` 1.AAC0832
2022-01-10 10:19 ` Marius Amado-Alves
0 siblings, 1 reply; 18+ messages in thread
From: 1.AAC0832 @ 2022-01-10 5:13 UTC (permalink / raw)
On 1/6/22 11:14 PM, Randy Brukardt wrote:
> "1.AAC0832" <z24ba7.net> wrote in message
> news:AOmdnX_3T5ObO0r8nZ2dnUU7-IHNnZ2d@earthlink.com...
> ...
>> Gnat wants FOUR params ... and it's the last "map" related
>> one that's most mysterious. I'd also seen examples using
>> only TWO params ... but the compiler balks.
>>
>> In any case :
>> Idx := Index
>> (Source => S,
>> Pattern => P,
>> From => Idx + 1);
>>
>> won't compile no matter what you put in "from".
>
> I use this sort of thing all the time (especially in the Trash-Finder spam
> filter), and it works fine. You never have to give the 4th parameter in
> these routines as they have a defined default which allows you to omit them.
> So it's highly likely that you've done something else wrong which is why
> nothing you try works.
>
> But you've given so little detail about your program, it's impossible to
> help. Ada resolution can be finiky, especially when a routine is overloaded
> as Index is, and that is also the case where it is difficult/impossible for
> a compiler to give an understandable error message. To get useful help
> around here, you need to provide a complete example (including all of the
> declarations and use clauses and with clauses). Otherwise, it just ends up
> being griping and people will tune you out.
>
> For instance, in the above, I have no idea what types S, P, and Idx have --
> and that matters a lot -- Ada is a very strongly typed language.
>
> Randy.
Yes ... VERY :-)
Hate typing long things ... made one-liners S2U() and
U2S() if you can guess what those are :-)
Unfortunately Gnat often gives rather generic, useless,
error messages. Not helpful. SOMETHING is wrong, but WHAT ?
You'd swear it was a Microsoft product ..........
Someone else here says that with unbounded searching the
"needle" is a straight-up string, not an unbounded. I'll
have to experiment.
Anyway, thanks for the help. This group has so much spam
I wondered if there were any real programmers here. Ada
is worth knowing something about.
Did get my fancy linked-list of linked-lists setup to
work correctly though :-) Had to write my own string-in-string
finder alas. But, more experiments are warranted. Still
wish those last two params had better docs ... they are
in rather a lot of library functions related to unboundeds.
It's kind a "Why, EVERYONE JUST KNOWS" thing ...
ANYway ... I like experiments. Some Ada is worth knowing.
Set up CP/M-86 on a VM recently and found an Aztec 'C'
compiler for it - retro FUN ! All work and no play ....
Oh, speaking of docs, that Aztec compiler docs were clearly
NOT written by some hired "technical writer" but by the
people who were hands-on writing the compiler. PAGES on
how binary stuff got set up, and how various compiler
flags could affect it. Memory and speed were PRECIOUS
back then ....
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-10 5:13 ` 1.AAC0832
@ 2022-01-10 10:19 ` Marius Amado-Alves
2022-01-11 5:20 ` 1.AAC0832
0 siblings, 1 reply; 18+ messages in thread
From: Marius Amado-Alves @ 2022-01-10 10:19 UTC (permalink / raw)
> Hate typing long things ... made one-liners S2U() and
> U2S() if you can guess what those are :-)
This is totally line with the strict typing of Ada (no implicit conversion).
Most of us abbreviate even more as "+".
Sorry, but I fail to see any reason the standard Ada.Strings Index functions would not work for your usecases. If possible please provide a succint explanation.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-10 4:46 ` 1.AAC0832
@ 2022-01-10 15:05 ` Simon Wright
2022-01-11 5:17 ` 1.AAC0832
0 siblings, 1 reply; 18+ messages in thread
From: Simon Wright @ 2022-01-10 15:05 UTC (permalink / raw)
"1.AAC0832" <z24ba7.net> writes:
> This group is so packed with spam that I wondered if anybody real
> still used it.
I was going to say "what?" but if I look via Google Groups I see what
you mean. Just had a merry few minutes marking posts as abuse.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-10 15:05 ` Simon Wright
@ 2022-01-11 5:17 ` 1.AAC0832
2022-01-11 11:33 ` Niklas Holsti
0 siblings, 1 reply; 18+ messages in thread
From: 1.AAC0832 @ 2022-01-11 5:17 UTC (permalink / raw)
On 1/10/22 10:05 AM, Simon Wright wrote:
> "1.AAC0832" <z24ba7.net> writes:
>
>> This group is so packed with spam that I wondered if anybody real
>> still used it.
>
> I was going to say "what?" but if I look via Google Groups I see what
> you mean. Just had a merry few minutes marking posts as abuse.
Heh heh ... welcome to the underlying reality. Taking
the red pill has consequences :-)
For decades I never used kill lists - now there must
be a hundred items in there .........
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-10 10:19 ` Marius Amado-Alves
@ 2022-01-11 5:20 ` 1.AAC0832
0 siblings, 0 replies; 18+ messages in thread
From: 1.AAC0832 @ 2022-01-11 5:20 UTC (permalink / raw)
On 1/10/22 5:19 AM, Marius Amado-Alves wrote:
>> Hate typing long things ... made one-liners S2U() and
>> U2S() if you can guess what those are :-)
>
> This is totally line with the strict typing of Ada (no implicit conversion).
> Most of us abbreviate even more as "+".
>
> Sorry, but I fail to see any reason the standard Ada.Strings Index functions would not work for your usecases. If possible please provide a succint explanation.
It is suggested that the "needle" is a String string
instead of an unbounded. I'll check that out and report
once I finish my other project.
Oh well, meanwhile, I just wrote one that DOES work
with unboundeds.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-11 5:17 ` 1.AAC0832
@ 2022-01-11 11:33 ` Niklas Holsti
2022-01-12 4:22 ` 1.AAC0832
0 siblings, 1 reply; 18+ messages in thread
From: Niklas Holsti @ 2022-01-11 11:33 UTC (permalink / raw)
On 2022-01-11 7:17, 1.AAC0832 wrote:
> On 1/10/22 10:05 AM, Simon Wright wrote:
>> "1.AAC0832" <z24ba7.net> writes:
>>
>>> This group is so packed with spam that I wondered if anybody real
>>> still used it.
>>
>> I was going to say "what?" but if I look via Google Groups I see what
>> you mean. Just had a merry few minutes marking posts as abuse.
>
> Heh heh ... welcome to the underlying reality. Taking
> the red pill has consequences :-)
So use comp.lang.ada through the Real(tm) USENET instead of Google Groups.
This group is not moderated, so there are occasional "meet the girls"
posts, but not enough to be troublesome.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Ok - WHAT are those "Maps.Identity" things ???
2022-01-11 11:33 ` Niklas Holsti
@ 2022-01-12 4:22 ` 1.AAC0832
0 siblings, 0 replies; 18+ messages in thread
From: 1.AAC0832 @ 2022-01-12 4:22 UTC (permalink / raw)
On 1/11/22 6:33 AM, Niklas Holsti wrote:
> On 2022-01-11 7:17, 1.AAC0832 wrote:
>> On 1/10/22 10:05 AM, Simon Wright wrote:
>>> "1.AAC0832" <z24ba7.net> writes:
>>>
>>>> This group is so packed with spam that I wondered if anybody real
>>>> still used it.
>>>
>>> I was going to say "what?" but if I look via Google Groups I see what
>>> you mean. Just had a merry few minutes marking posts as abuse.
>>
>> Heh heh ... welcome to the underlying reality. Taking
>> the red pill has consequences :-)
>
>
> So use comp.lang.ada through the Real(tm) USENET instead of Google Groups.
I don't, and won't, use GG. Google shouldn't be allowed to
pretend it owns Usenet. It'll also spy on you and sell
your 'profile' to, well, anybody.
But you CAN get the unfiltered feed elsewhere. It's "truth",
even if ugly
> This group is not moderated, so there are occasional "meet the girls"
> posts, but not enough to be troublesome.
Um ... DO look at an unfiltered feed sometime. More
than "occasional" - like 20% of posts .....
Anyway, I'm halfway through my current obligatory project
and then I'll get back to more Ada.
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2022-01-12 4:22 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 0:54 Ok - WHAT are those "Maps.Identity" things ??? 1.AAC0831
2022-01-05 5:49 ` Rod Kay
2022-01-07 2:31 ` 1.AAC0832
2022-01-07 3:39 ` Gautier write-only address
2022-01-07 4:14 ` Randy Brukardt
2022-01-10 5:13 ` 1.AAC0832
2022-01-10 10:19 ` Marius Amado-Alves
2022-01-11 5:20 ` 1.AAC0832
2022-01-07 11:48 ` G.B.
2022-01-10 4:49 ` 1.AAC0832
2022-01-05 13:01 ` Jeffrey R.Carter
2022-01-07 2:41 ` 1.AAC0832
2022-01-07 9:49 ` Jeffrey R.Carter
2022-01-10 4:46 ` 1.AAC0832
2022-01-10 15:05 ` Simon Wright
2022-01-11 5:17 ` 1.AAC0832
2022-01-11 11:33 ` Niklas Holsti
2022-01-12 4:22 ` 1.AAC0832
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox