in reply to Re: Math::BigInt new
in thread Math::BigInt new
Agreed. However, here is the first part of new:
If it gets to the last line, and $class == 27, then $class must have been changed somewhere?sub new { # create a new BigInt object from a string or another BigInt object. + # see hash keys documented at top # the argument could be an object, so avoid ||, && etc on it, this w +ould # cause costly overloaded code to be called. The only allowed ops ar +e # ref() and defined. my ($class,$wanted,$a,$p,$r) = @_; # avoid numify-calls by not using || on $wanted! return $class->bzero($a,$p) if !defined $wanted; # default to 0 return $class->copy($wanted,$a,$p,$r) if ref($wanted) && $wanted->isa($class); # MBI or subclass $class->import() if $IMPORT == 0; # make require work my $self = bless {}, $class;
And generally speaking, if I want a new object from an existing object, shouldn't the existing object be able to create one for me? Or do I have to go around doing this?
my $y = {ref $x}->new();
(or whatever the syntax is for that)
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Math::BigInt new
by tobyink (Canon) on Sep 27, 2012 at 16:13 UTC | |
Re^3: Math::BigInt new
by remiah (Hermit) on Sep 27, 2012 at 23:12 UTC |
In Section
Seekers of Perl Wisdom