Sujet : Re: substr() - copying or not copying, that is here the question.
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.awkDate : 01. Jun 2025, 14:47:38
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <101hlls$24vmc$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 01.06.2025 13:53, Kenny McCormack wrote:
In article <87h60zrbea.fsf@bsb.me.uk>, Ben Bacarisse <ben@bsb.me.uk> wrote:
...
An alternative (depending on the context) would be to consider an
extension that provides an index function with a third argument giving
the initial offset. I've not looked at how extensions get access to
GAWK strings, so this many not be as easy as it sounds, but I would
guess that it might be relatively simple to do.
The thing about writing GAWK extensions is that the first one is hard,
because it is all new stuff to learn (and you have to establish your own
conventions for how your extensions are going to look, code-wise). [...]
You are describing the individual practical accustoming to writing
own extensions.
Okay. My viewpoint was another.
It's IMO a problem if folks write own index() extension in his/her
own version and code quality. We see proliferations of own versions
in all areas of IT; and I don't see it as a desirable goal.
I wouldn't want two (or three) 'match' functions (match(), match_a(),
match_ae()) or similar.[*]
If a function provides actually the same basic task, and it should
get controlled (like program options[**]) with optional arguments,
that would be what I'd think be the right way.
By the way, if you find the substring at position 900005 (i.e., the 5th (*)
char of the searched string), should the function return 5 or 900005?
(*) Or 6th; I'm not sure of my exact notation at this point.
I don't think the decision is crucial since (I think) you could
derive one value from the other (provided the given arguments).
The behavior should probably be discussed to find the advantages
of one or the other option. Yet I'm not sure whether the usefulness
of such a match() function extension is commonly accepted.
(Anyway. Core evolutions are deprecated. And it won't happen.)
Janis
[*] I find it already a bit, umm, strange to have three different
substitution functions in GNU Awk (two historic/standard and one
somewhat generalized and extended).
[**] Do we need grep, egrep, fgrep - on my system they are not
even hardlinks -, or should grep be used with options grep -E,
grep -F ?