develooper Front page | perl.perl5.porters | Postings from March 2007

hooking IV => NV upgrade

Thread Next
From:
Tels
Date:
March 30, 2007 06:31
Subject:
hooking IV => NV upgrade
Message ID:
200703301531.33011@bloodgate.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Moin,

consider the following:

	perl -Mbigint -wle '$x = 1 + 1; $x **= 255; print $x;'

this prints 2 ** 255, as it should. However, it also uses BigInt et. al. for 
calculating 1+1, which is a bit silly (read: slow). Plus, the actualy 
numbers are not Perl build-in types, but objects (blessed hash) and this 
implementation details frequently shines through, even tho the code goes to 
great lengths to make it transparent.

So, recently I had a crazy idea: What it Perl could detect that the 
number/operand/result overflows and upgradesi it? And, we already have such 
a mechanism in place, when IVs overflow they are upgraded to NVs.

However, I do not think there is yet a way to hook into this upgrade via XS, 
or is there?

All the best,

Tels

- -- 
 Signed on Fri Mar 30 15:26:56 2007 with key 0x93B84C15.
 View my photo gallery: http://bloodgate.com/photos
 PGP key on http://bloodgate.com/tels.asc or per email.

 "Karate is a form of martial arts in which people who have had years and
 years of training can, using only their hands and feet, make some of the
 worst movies in the history of the world."

  -- Dave Barry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iQEVAwUBRg0tVHcLPEOTuEwVAQIF5wf+NBOgI+ezv8URRzua7Tv9LmPkkMAj4+Ne
yaZ2DZA8W9BvSA6LZFlBfZuGhWLNG8/pv7P48Dsy0jFP2IMQ3xkd+NRsW1+rrCxE
UcPWXXMg+RoqMgAwwi73GvegUxGTWqm7r5m3CZkhNBJd73rOypHuIsRBX+eGY9EV
ouoyXsbjXPV2Ugxnfmtrog1n3aon3vKZQ63n2vRigqvlLt2AGoICHQehz+ZMMN7o
E3OAQZT4yAXmj/2dStTsfJc7cYTi7WAsDDEneMFSz7UXHTEcBywLgOPFBXA8pw36
/chFlDb8QFS3tQfKQYd6Z68ZzbcHY4kesMFKfy5BGCs6USGD1/D3Jg==
=2vke
-----END PGP SIGNATURE-----

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About