-----BEGIN PGP SIGNED MESSAGE----- Moin, On Saturday 25 October 2003 21:23, Tels wrote: > Moin, > > I got a bugreport from Dennis Boylan: > > # perl -Mbigint -le 'print cos(4)' > Operation `cos': no method found, argument in overloaded package > Math::BigInt at -e line 1. I opted no to the following plan: * Add an option ':fallback' to BigInt, which tricks overload to make cos(Math::BigInt->new(1)) equivalent to cos(1) * add option to Math::Big to overload cos(), sin(), atan2() and exp() so that they produce BigFloats. So: * default BigInt dies with "no method found. * use BigInt ':fallback'; is equivalent to no BigInt at all AFA cos/sin/atan/exp are concerned (e.g. cos(1) returns 0.54etc to 10 digits approcimately) * use BigInt ':fallback'; use Math::Big qw/:cos :sin :atan2 :exp/; will produce BigFloats (selectively) There is only one snag: te@null:~> cat cos.pl #!/usr/bin/perl -w package Test; # without the "''" nomethod is never called use overload '""' => sub { $$_[0]} ; sub new { my $a = $_[0]; bless \$a, 'Test'; } sub import { overload->import ( nomethod => sub { &{'sCORE::' . $_[3]}( $_[0], $_[1], $_[2] ); print "nomethod ", join(":", @_), "\n"; }, ); } package main; use Test; print CORE::cos(1),"\n"; print cos(Test->new(1)),"\n"; te@null:~> perl cos.pl 0.54030230586814 Undefined subroutine &sCORE::cos called at cos.pl line 18. I tried UNIVERSAL::cos, main::cos etc, but they all come back as "undefined". However, a plain "CORE::cos" works just fine. What do I do wrong? *puzzled* Best wishes, Tels - -- Signed on Sat Nov 1 17:31:45 2003 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email. "Remember: If the game let's you do it, it's not cheating." -- Xarax -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) Comment: When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl. iQEVAwUBP6Pf8ncLPEOTuEwVAQGfrgf9HsLCXEXMvL71+tpadn4eJw+ezGri3nia E1ZmxCrsrOGjPQcmfQbPpzUggIcMq50UibDrWj28utCbDu0Azdjk9okADWSCW+fT 0brmWy47Ic38tSCHPAYH5AntpRTU/B+tI6F6RtrpjHknYXRqhQj10HvJmHE13Xpb /VEBdTmzephzs5O3mDyBQPeypnZ9ZUWIiPpLlZqsjD+aAqu+ia4xdUTVUsllt8vG 7UTKxjlYIJHNdTvOkdcHq9XtDgN4SuhLtRAsMtIcoOFdgMn53/sUwejbfqTfWtSf Rt7Farq6QfIxGBIN5JoZCwnTj9oNWIxkgZ8+5mN+sbOzikPxDOtDUA== =L18Y -----END PGP SIGNATURE-----Thread Previous | Thread Next