Howdy!

OK. Short answer: both guilty, sort of. Consider 'foo.pl':

#!/usr/bin/perl use strict; use warnings; use Set::Scalar::Valued; test_args(Set::Scalar::Valued->new()); sub test_args { my @opt_args; while (my $arg = shift) { if (ref($arg) eq 'ARRAY') { push @opt_args, @$arg; } else { push @opt_args, $arg; } } print scalar(@opt_args), "\n"; }

Now consider the following session via 'perl -d foo.pl':

main::(foo.pl:6): test_args(Set::Scalar->new()); + DB<0> s Set::Scalar::Base::new(/Library/Perl/5.8.6/Set/Scalar/Base.pm:68): 68: my $class = shift; + DB<0> r list context return from Set::Scalar::Base::new: 0 Set::Scalar=HASH(0x18092cc) 'elements' => HASH(0x194c7d4) empty hash 'universe' => Set::Scalar::Universe=HASH(0x18d312c) 'elements' => HASH(0x18b1db0) empty hash 'null' => Set::Scalar::Null=HASH(0x18acce4) 'universe' => Set::Scalar::Universe=HASH(0x18d312c) -> REUSED_ADDRESS 'universe' => undef main::test_args(foo.pl:10): my @opt_args; + DB<0> n main::test_args(foo.pl:11): while (my $arg = shift) main::test_args(foo.pl:12): { + DB<0> s Set::Scalar::Base::size(/Library/Perl/5.8.6/Set/Scalar/Base.pm:122): 122: my $self = shift;

I'm now puzzling over just how one goes from "my $arg = shift" to Set::Scalar::Base::size... and I return from a bit more digging.

Set::Scalar::Base overloads 'bool' by calling 'size'. Aha!

When I change the while condition to do "defined my $arg = shift", it works correctly. Methinks a patch is in order...

This has been an interesting course of investigation. I hope y'all have not found it boring.

yours,
Michael

In reply to Re: Difficulty with Object::InsideOut by herveus
in thread Difficulty with Object::InsideOut by herveus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.