Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

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


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

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


Comment on Re: Re: Re: Re: Thoughts on some new operators for perl (6 or 7)
Download Code
Re: Re: Re: Re: Re: Thoughts on some new operators for perl (6 or 7)
by Juerd (Abbot) on Mar 10, 2004 at 15:03 UTC

    If you want mutating on an object, than you should define method to work that way already.

    No, that is exactly the opposite of what I want. That way you get again the mess that Perl 5 also has: some are mutating, some are not. I want everything to be non-mutating by default with some kind of modifier to make it mutating. This thread made me think of .= and I think it is a very good candidate, because it works much like the other op= operators: foo op= bar does the same as foo = foo op bar, but with possible optimizations.

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

      In practice, you're not going to get that, unless you convince every Perl programmer to lay out their class design so they respect the mutating/non-mutating idiom.

      Also, is it your habit to downvote every node you happen to disagree with?

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

      Note: All code is untested, unless otherwise stated

        In practice, you're not going to get that, unless you convince every Perl programmer to lay out their class design so they respect the mutating/non-mutating idiom.

        Not really. It'd be relatively simple to build in fallback support. That is: if there is no mutating variant, the non-mutating variant can be used with normal assignment and if there is no non-mutating variant, the mutating variant can be used with a temporary copy. The first thing happens in Perl 5 already with tied values: += is optimized for normal scalars, but for tied scalars separate FETCH and STORE calls take place.

        Also, is it your habit to downvote every node you happen to disagree with?

        No, only if the node is a proposal. Is it yours?

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2014-09-18 03:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (107 votes), past polls