in reply to Only sometimes deprecated? "Unescaped left brace in regex is deprecated"

My versions of perl don't have the error so I can't test, but I do notice that in your example the first curly bracket is also the first character of the regex, where it can't be the start of a quantifier. So maybe there are still some special cases (like - and ] don't have to be escaped when coming first in a character class), where { is considered unambiguous. This would limit future extensions to cases where {THING} syntax only works as a modifier of the previous token (maybe TOKEN{EXPR} where EXPR validates the current repeat count, for consistency).

  • Comment on Re: Only sometimes deprecated? "Unescaped left brace in regex is deprecated"

Replies are listed 'Best First'.
Re^2: Only sometimes deprecated? "Unescaped left brace in regex is deprecated"
by LanX (Saint) on Jun 02, 2017 at 16:22 UTC
    Thanks! :)

    hmm, the perldelta doesn't talk about quantifiers, and the ambiguity would already have existed before.

    I thought it's deprecated to facilitate parsing extended syntax like /abc(?{print "Hi Mom!";})def/

    see perlretut for other examples

    so I'm not sure if it's about quantifiers...

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      Because (? is invalid syntax on its own, in any (?X pattern the X is unambiguously special or incorrect, but never litteral. perlre however does talk about extending the quantifier syntax.

      like making the lower bound of a quantifier optional
      And any new syntax that's not a modifier can be added with a (?X pattern. That's why I concluded that disallowing unescaped litteral { was probably an opening toward new quantifier syntax (because { only introduces quantifiers). I thought of something like /.{{!($_ % 3)}}/ instead of /(?:.{3})*/ (it's harder to read though ...), or even "3ABCD" =~ /(\d)(.{{$1}})(.*)/; #(3,"ABC", "D"). But that's wild guesswork

      PS: How do you like all those unbalanced left tokens? ^^"

        Thanks, in hindsight all these explanations and reasonings make sense.

        I just expect documentation to be clearer.

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!