Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Thoughts on some new operators for perl (6 or 7)

by Juerd (Abbot)
on Mar 10, 2004 at 07:14 UTC ( #335377=note: print w/ replies, xml ) Need Help??


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' }


Comment on Re: Thoughts on some new operators for perl (6 or 7)
Select or Download Code
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://335377]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-12-25 00:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls