Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I'm afraid I'm on the "chained setters are stupid" side of things. What exactly are you accomplishing? Mostly, folks who think it's cool seem to be rationalizing an attempt to fit more junk on one line. There's nothing intuitive about it and it's probably just going to cause confusion down the road.
    • What I'm accomplishing is grouping things together that logically belong together. Plenty of times I've seen cut-n-drool programmers slap some code in the middle of a chunk that shouldn't be split up only to break things and scratch their heads trying to figure out why. This makes it tougher to do that.

      No offense, but I don't buy the "confusion down the road" argument. Why is this confusing? Because it's new? No one has a problem chaining accessors and they do it every day in Java. The first time I

      • The main problem with chained mutators is that it requires cooperation of all the mutators to work properly. It adds extra complexity to all of the mutator implementation to gain a little convenience for the caller.

        Also, sometimes it makes sense for mutators to return something. For example, returning the previous value can be useful. Or if the mutator constructs an internal object, then returning that object might make sense. In Perl, the lack of exceptions frequently means returning error indicators.

        It is possible to introduce mysterious bugs when the wrong object is returned. What happens when the mutator returns a different object? If the returned object is of the same class, then no errors will be thrown. If it is a different class, then Java's type checking will usually catch it. But in Perl, it is quite possible to continue without any errors but getting the wrong behavior.

        • It adds extra complexity to all of the mutator implementation to gain a little convenience for the caller.

          Surely that's a good thing! When you make it easy for the implementor at the expense of the user, you end up with something like Ant [] where you have to write XML. I'd much rather use Module::Build or even ExtUtils::MakeMaker for all their faults (and the former has many fewer faults than the latter), they're easier to use than either writing my own Makefile or writing an XML file.