in reply to A work of art

sub new { my $class = shift; my $self = { %fields, }; bless $self, $class; return $self; }

That's not art. It's a bug. %fields is a global. You're creating not actually using any of the parameters to ->new.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Replies are listed 'Best First'.
Re^2: A work of art
by Tanktalus (Canon) on Feb 14, 2006 at 00:54 UTC

    Calling it a bug may be a bit premature. Perhaps %fields holds the default state of a new object, and new isn't intended to take parameters. Those fields should be manipulated otherwise. At the very least, $self isn't a reference to %fields itself, but a copy of the contents of %fields.

    There is a completely plausible explanation for this code, IMO. Without greater context, it's impossible to see. Besides, it doesn't, IMO, detract from the rest of the OP's post and probably didn't need to be singled out.

      Ya sure. I disagree. Oh well? %fields isn't named like it's supposed to provide defaults, it's named like the author intended it to be more local. If the thing really is some defaults then it ought to look like it. It's not good code, as is.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

        As a work of modern art, it must have been intended to be ugly, flawed, and comment-provoking. ;-)
        --
        Ytrew, who *really* doesn't get modern art...