[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Suggestion for new pattern item like %bxy
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 15 Feb 2017 07:08:57 +0200
2017-02-15 2:32 GMT+02:00 Tony Papadimitriou <firstname.lastname@example.org>:
> I would like to suggest the addition of a new pattern item which will
> behave just the like the %bxy one but will return the match without
> the xy part.
> Does anyone else see any merit (or problem, other than the usual
> minimalism objections) in this proposal?
Every pattern can be looked at in two ways.
Yang: What does it provide under gmatch?
Yin: What does it leave behind under gsub?
Let's say your pattern will be called %B. The first question to ask is:
"Is there anything %B can do that %b cannot do, or vice versa?"
and one must look at it from both perspectives.
Under Yang it is a tie. It is just as easy to re-concatenate the delimiters
to the result of %B as it is to :sub them away from the result of %b.
Under Yin %b wins. It is easy to put two delimeters back in but you will
need to repeat the whole exercise in order to take empty balanced pairs
of them out.
I.e. if we have only one of %b and %B, then it must be %b. This kind
of reasoning may well have been part of the design of how %b operates.
Now to your exact question. It is specious to admit only problems "other
than the usual minimalism objections". It is like asking "Apart from your
usual rant that we only have a single garage and one income, would
it not be nice if our family had a second car?"
Minimalism objections cannot be brushed aside like that. Let me
1. It uses up syntax space.
2. It demands more of implementors of compatible libraries.
3. It makes the description of patterns a little longer and a little
harder to follow at first reading.
The question to ask, when considering the addition of a new feature,
is not "Is there any merit in it?" (of course there is, if one can exhibit
even one case where it saves effort) but "Does it offer enough to
offset the usual minimalist objections?". In other words, does it make
real progress or is it a case of feature creep?