On Wed, Jun 01, 2016 at 10:56:42PM -0600, Karl Williamson wrote: > This came up on another thread, but I think it should get its own airing. > > qr/ ^ {1,3} /x, warns with "Quantifier unexpected on zero-length expression" > > qr/ ^ * /x warns instead with "^ * matches null string many times", and > generates code that will run a very long time. > > qr/ ^ ? /x doesn't warn. Nor does qr/ ^ {0,1} /x. But qr/ ^ {0,2} /x > does warn. > > It is nonsensical to use a quantifier on an assertion, and for Perl to > try to do so is not likely at all to be DWIM. So I believe we should > deprecate these. I'd say it's about as nonsensical as multiplying 0 with something, or doing C< "" x 5 >, but we aren't deprecating those either. I grant you, there are many examples where it doesn't make sense, but it makes generating patterns easier if "$SUB_PATTERN$QUANTIFIER" is always valid, regardless whether $SUB_PATTERN is a zero-length expression. Just as generated code doesn't have to care whether something on the LHS of a multiplication is 0. AbigailThread Previous | Thread Next