develooper Front page | perl.perl5.porters | Postings from March 2021

Re: Perl feature wish: quote-word array-ref operator

Thread Previous | Thread Next
From:
shmem
Date:
March 14, 2021 17:31
Subject:
Re: Perl feature wish: quote-word array-ref operator
Message ID:
alpine.DEB.2.21.2103132337330.7830@mail.mgm-net.de
From the keyboard of Todd Rinaldo [12.03.21,22:29]:

> 
>
>       On Mar 12, 2021, at 9:11 PM, Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:
> 
> On Wed, Mar 10, 2021, at 2:35 AM, Smylers wrote:
>       Eric Wong writes:
> 
> > One thing that is AFAIK conflict-free could be using a suffix modifier
> > (similar to regexp modifiers):
> > 
> > qw[ a b c ]r
[...]
> This example is meant to make the point, not to be exactly what we want:
> 
> qz:d[ ... ]      # :d means "delimiter determines type" so this gets an arrayref
> qz:d{ ... }      #    ...same thing, but we get a hashref
> 
> qz:i{ a $b c }   # :i means interpolative
> 
> qz:x{ this #foo
>       rules }    # :x is like /x on regex; allow comments
> 
> # ...all together now...
> qx:xid[
>   apples
>   bananas
>   cherries
>   $other # <- durians?
>   eggplant
> ]
> 
> 
> You've pretty much summarized everything I've ever wanted from qw. For me the interpolative
> and the comments are the killer feature I always want.
> 
> Todd

+1

This is what I always wanted, too. And "qa" with modifiers doesn't look
unfitting: "quote anything - as:" as mnemonic, where :d should be default,
because all of () {} [] could be implicit. With alternative delimiters,
the flags "h" and "a" could denote HASHREF and ARRAYREF, "l" just a list,
and "s" force all arguments to be treated as strings as in qw().

While I cherish that construct, it could morph into something as unwieldy
as the smartmatch operator...

0--gg-

-- 
_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                               /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
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