develooper Front page | perl.perl5.porters | Postings from July 2016

Re: [perl #128241] Deprecate (or change) /$empty_string/

Thread Previous
Aristotle Pagaltzis
July 11, 2016 19:39
Re: [perl #128241] Deprecate (or change) /$empty_string/
Message ID:
* Father Chrysostomos via RT <> [2016-07-11 17:36]:
> On Mon Jul 11 07:39:18 2016, demerphq wrote:
> > On 11 Jul 2016 10:13, "Dave Mitchell" <> wrote:
> > > 1) leave literal // with its 'last regex' behaviour for now
> >
> > I would like to deprecate it in m// but keep it in s/// where it at
> > least has some utility.
> I would prefer to keep it in both, since it makes it simpler to
> explain.

I went back and forth over this a bit.

My initial inclination was the same as yours: the less special a special
case is, the better.

But when I imagined making that claim, I realised it doesn’t really help
in his situation: we already have a special case, and you just have to
memorize what works where. There already isn’t much systematic about it.

And in a way it could even be easier to understand and explain if the
reuse-last-pattern thing was a feature of s/// and didn’t clog the rest
of the documentation. There would be just one kind of operation where
you ever saw this in code, and it would look suitably odd to signal that
something unusual is going on (“how could a substitution of nothing have
an effect?”) and the documentation for that operation is the place that
would explain it. Simple and coherent and discoverable. It almost makes
the feature sound like a good idea!

But my next realisation was that we’re not in a vacuum: code may have to
work across Perl versions. And documentation has to explain the issues
relating to that. Both tasks are easier if divergences are kept small.

So ultimately I think adding reuse-last-pattern as a special feature of
s/// (and s///) alone would make sense if we were starting from scratch,
but keeping it in m// is preferable given that we do have a historical
context and that the context is what it is.

Aristotle Pagaltzis // <>

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About