OTOH no less than Damian Conway is a big fan of customized versions of Perl

Though, you'll note that I always customize the syntax, never the semantics. And I always do it in such a way that you have to start the customized code with an explicit use Some::Module::Name directive.

I'm certainly not in favour of customizations that change semantics by stealth.

As for the original proposal to make built-ins modify their arg in a void context, I know that Larry has considered this and is still working through some of the problems with the idea. Like the fact that the same piece of code inside a sub can be in both void and non-void contexts when called from different points in the code (as others have pointed out in the thread).

Personally, if we see anything like this, I think it is far more likely that we'll see an explicit syntax for it. There's a strong analogy here to the proposal that operators automatically vectorize when given array arguments. Larry rejected that idea and came up with explicit hyperoperators instead. If he likes the idea of in-place versions of built-ins, I'd expect we'd see some new pseudo-operator to mark them as in-place.

From that perspective, the extension of $var =~ &whatever to mean $var = whatever $var does have some merit. Though it's still debatable whether it's worth the bother, given you can already so easily write:

sub apply (&@) { my $func = shift; $_ = $func->($_) foreach @_; } apply {lc} $var; apply {uc} $var1, $var2; apply {abs} @values; # etc.

Or in Perl 6:

sub apply (&func, *@args) { $_ = func($_) foreach @args; }

Or maybe even use an (as yet theoretical) "iterative superposition":

sub apply (&func, *@args) { each(@args) = func(each @args); }
I just invented that notion on the spot, but it will definitely go into the next release of Quantum::Superpositions, and I'll also pitch it to Larry (along with any and all) for Perl 6.

In reply to Re: Re (tilly) 1: DWIM Part Nineteen: Unary Operators in Void Context by TheDamian
in thread DWIM Part Nineteen: Unary Operators in Void Context by CheeseLord

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.