Opinions needed on neg and absolute

Joshua Juran jjuran at gmail.com
Mon Aug 30 23:12:58 UTC 2010


On Aug 30, 2010, at 3:45 PM, Paul C. Anagnostopoulos wrote:

> As an example of a PMC that inherits from Integer and might rely on  
> the current behavior, I give you Boolean. It inherits 'neg' and  
> relies on the fact that it does not promote to implement the  
> following bizarre behavior:
>
> -(Boolean true) => true
> -(Boolean false) => false
>
> I will simply implement 'neg' in Boolean to preserve this whackiness.

What's so odd about that?  If you think of 'false' as zero, then the  
inverse of zero equals zero (false) and the inverse of any non-zero  
integer is non-zero (true, e.g. 1 -> -1).  Though if Boolean is a one- 
bit integer, it must be an unsigned type, and -true will wrap around  
to true anyway.

Josh




More information about the parrot-dev mailing list