Front page | perl.perl5.porters |
Postings from April 2018
[perl #132851] Empty pattern-match modifiers should be documented
From:
Karl Williamson via RT
Date:
April 17, 2018 04:25
Subject:
[perl #132851] Empty pattern-match modifiers should be documented
Message ID:
rt-4.0.24-21818-1523939143-931.132851-15-0@perl.org
On Wed, 14 Mar 2018 10:02:34 -0700, demerphq wrote:
> On 14 March 2018 at 17:45, Father Chrysostomos via RT
> <perlbug-followup@perl.org> wrote:
> > On Wed, 14 Mar 2018 09:21:38 -0700, khw wrote:
> >> On Tue, 13 Feb 2018 03:09:29 -0800, demerphq wrote:
> >> > On 13 Feb 2018 16:59, "Dave Mitchell" <davem@iabyn.com> wrote:
> >> >
> >> > On Tue, Feb 13, 2018 at 05:08:46AM +0100, demerphq wrote:
> >> > > > Ah. Good catch. Well then let's fix the code here, not the
> >> > > > doc.
> >> > >
> >> > > + case ')':
> >> > > + vFAIL("(?) without any modifiers is illegal.");
> >> > > + break;
> >> >
> >> > I think the point being made in the original perlmonks post was
> >> > that
> >> > perl *should* support zero flags, because as our docs say:
> >> >
> >> > This is particularly useful for dynamic patterns, such as those
> >> > read
> >> > in from a configuration file, taken from an argument, or specified
> >> > in
> >> > a table somewhere.
> >> >
> >> > And "dynamically generated" can easily result in zero flags. So
> >> > the
> >> > OP
> >> > wanted to clarify whether it was safe to assume that zero flags
> >> > was
> >> > supported.
> >> >
> >> >
> >> > I'm fine either way but for the record I was thinking it should be
> >> > forbidden so as to catch typos.
> >> >
> >> > Yved
> >>
> >> I'm in favor of catching typos (such as the one in the line above :)
> >> )
> >> I see two other alternatives. One is to warn instead of die, and
> >> the
> >> other is
> >> to warn or die only under 'use re "strict"'
> >
> > I would prefer that we keep it loose. It is longstanding behaviour,
> > and fixing it provides little gain. (How likely is someone to type
> > (?) by mistake without noticing it? If the ) was added by mistake
> > the pattern won’t compile.)
>
> FWIW, I am not convinced. I can easily someone making this mistake,
> and then adding a new open paren to deal with it
>
> Yves
Discussion here has stalled. Another option is to document and warn, but only under 're strict'. Then longstanding code will be unaffected, but there is a way for someone to find these.
--
Karl Williamson
---
via perlbug: queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=132851
-
[perl #132851] Empty pattern-match modifiers should be documented
by Karl Williamson via RT