Subject: | Interesting interface when using new_$COLORSPACE |
Date: | Tue, 24 Sep 2013 09:37:17 +0200 |
To: | bug-Graphics-ColorObject [...] rt.cpan.org |
From: | Herwin Weststrate <herwin [...] quarantainenet.nl> |
The call sequence when using, for example, new_RGB is a bit weird. The
first two lines of this method:
sub new_RGB {
my ($pkgname, $rgb, %opts) = @_;
my $this = &new($pkgname, %opts);
When we call it, we pass two explicit arguments: a $rgb (arrayref with
the RGB values) and an options hash. This options hash is passed to the
sub new, where this is done:
sub new {
my ($pkgname, @opts) = @_;
...
my $col = &Graphics::ColorObject::namecolor($opts[0]);
Suddenly this options hash is treated as an array and the first item
(which is a random key of the hash, since hashes don't guarantee any
ordering) is passed to the namecolor method, and some magic happens if
that returns anything that isn't undef. Since we cannot rely on ordering
in the hashes this actually means that this introduces random behaviour.
--
Herwin Weststrate
Software Developer
Quarantainenet BV
T: 053-7503070