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.
| [reply] [d/l] [select] |
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
| [reply] [d/l] |
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?
| [reply] [d/l] |