develooper Front page | perl.perl5.porters | Postings from May 2015

The null pattern design mistake

Thread Next
Aristotle Pagaltzis
May 31, 2015 13:44
The null pattern design mistake
Message ID:
In-Reply-To: <>

* Tony Cook via RT <> [2015-05-12 02:30]:
> Or we could take /$null/ meaning 'use the last match' out the back and
> bury it.

Having the empty pattern mean “use the last matched pattern” is a fine
convention for a text editor, which is where it came from. But at least
since regexp objects (qr//) were added to Perl, there has been a way to
explicitly refer to patterns as first-class values. With that given, the
right peg to hang this feature off of is a ${^LAST_MATCHED_PATTERN} (or
whatever it be called), as opposed to a special case in pattern syntax.

I would really like to see that happen eventually.

It’s going to require a long deprecation cycle. But fortunately this is
a case where the replacement can be introduced before the bad design is
phased out, which allows a graceful roll-over with a long lead time.

Aristotle Pagaltzis // <>

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