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 propose a change instead of a removal,

    ref ($proto) || $proto;

    should be changed to:

    ref ($class) || $class;

    This would keep it in a OOP wording and possibly make it more essential for Perl-OOP beginners to understand what is going on.

    The construct is quite essential (I personally always use it).

    If you use inheritance, the result of not using could be strange since many people would perhaps not understand why their inheritance does not work and errors, which might be quite difficult to debug will occur

    • No, I doubt this was the kind of thing he was looking for. You should use 2-argument bless, but not one this complex. The form you ought to be using should simply look like
      sub new {
          my $class = shift;
          my $self = ... # any kind of ref, any data
          return bless $self, $class;
      The idea is that it's bad to make one constructor both for actually making a new object (class method), as for cloning (object method). Probably nobody ever uses new() as an object method, I'm sure. So don't make the API more complex by providing a mostly useless and confusing, and probably buggy, option.

      The most active high profile opponent of this complex abomination must be Randal L. Schwartz, AKA merlyn []. I'm quite sure he'll step in this discussion at one point, but at this time, I'll just point to one of his posts on PerlMonks [].