Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the boolean CPAN distribution.

Report information
The Basics
Id: 65536
Status: resolved
Priority: 0/
Queue: boolean

People
Owner: Nobody in particular
Requestors: james2vegas [...] aim.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Overload perl booleans at import time
Would be nice if boolean provided an import time option to overload perl's booleans to be blessed into booleans, like this:

Show quoted text
# enable modifying true and false
&Internals::SvREADONLY( \ !!0, 0);
&Internals::SvREADONLY( \ !!1, 0);
Show quoted text
# turn booleans into blessed booleans:
${ \ !!0 } = boolean::false;
${ \ !!1 } = boolean::true;
Show quoted text
# make true and false read-only again
&Internals::SvREADONLY( \ !!0, 1);
&Internals::SvREADONLY( \ !!1, 1);


After this the following prints "boolean boolean 1 0":
print( ref(1 == 0), ' ', ref(1 == 1), ' ', (1 == 1), ' ', (0 == 1), "\n");



Added in 0.28 Thanks for the great idea. Sorry it took so long.