develooper Front page | perl.perl5.porters | Postings from August 2010

Re: Any opposition still to the idea of syntax indicating defaultregex modifiers?

Thread Previous | Thread Next
From:
Ben Morrow
Date:
August 11, 2010 10:17
Subject:
Re: Any opposition still to the idea of syntax indicating defaultregex modifiers?
Message ID:
20100811171704.GA84244@osiris.mauzo.dyndns.org
Quoth public@khwilliamson.com (karl williamson):
> 
> +Starting in Perl 5.14, a C<.> (dot) immediately after the C<?> is a
> +shorthand equivalent to C<-imsx>.  Any positive or negative flags may
> +follow the dot, so
> +
> +    (?.x-i:foo)
> +
> +is equivalent to
> +
> +    (?x-ims:foo)
> +
> +(The C<-i> wasn't necessary, but did no harm.)

FWIW I'm not convinced allowing (?.-i:) is useful. It's always
redundant, and I suspect would just be confusing.

The way I would document this is

    (?.xi:foo) has exactly the flags /xi, regardless of where it is
    interpolated.

    (?x-i:foo), by contrast, will 'inherit' flags from the outside if
    they aren't specified explicitly.

I see (?.xi:) as the 'simple' case, and the existing syntax as more
complicated. It's only a side-effect of the implementation that it's
easier to inherit flags when interpolating than to preserve them.

Yves: if it helps, (?x-s:foo) is analogous to chmod a+r-w foo, and
(?.x:foo) is analogous to chmod a=r foo.

Ben


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About