http://www.perlmonks.org?node_id=335377


in reply to Thoughts on some new operators for perl (6 or 7)

I think it is very hard to read and for something that nobody does very often. (It'd make Perl like PHP, but with non-alphanumeric operators...) Introducing at least 8 new operators just to save a few characters is not worth it for such a rare occasion.

||= and //= are not comparing operators like > and <. They aren't comparison operators. They're normal binary operators that happen to short circuit. Syntactically they work like +, so they deserve a mutating variant, just like the other binary operators:

|| ||= && &&= ^^ ^^= // //= + += ~ ~= - -= * *= / /= % %= +& +&= ~& ~&= +| +|= ~| ~|= +^ +^= ~^ ~^= +< +<= ~< ~<= +> +>= ~> ~>= x x=
I wouldn't be surprised to see . get a .=.

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Replies are listed 'Best First'.
Re: Re: Thoughts on some new operators for perl (6 or 7)
by hardburn (Abbot) on Mar 10, 2004 at 14:17 UTC

    .= is already in Perl5. But the period is a completely different operator in Perl6, and .= doesn't make sense for its new purpose (it's for obj.method calls, just like many other OO langs).

    ----
    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

      .= doesn't make sense for its new purpose

      If you can't imagine a function for it, it automatically does not make sense?

      It could very well become a mutator for objects. As $foo += 5 equals $foo = $foo + 5, $foo .= lc could equal $foo = $foo.lc. Especially for @foo.sort and @foo.=sort, this would be great to have.

      I've been wanting mutating and non-mutating versions of builtins for a while now, and this seems to me a good way to do it.

      See also Re: Re: What should be returned in scalar context?.

      Does it make sense now?

      Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

        Sense, yes. But pulling the method and object apart like that is uglier than its worth, IMHO. If you want mutating on an object, than you should define method to work that way already.

        ----
        : () { :|:& };:

        Note: All code is untested, unless otherwise stated