X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Foverload.pm;h=ba96bc9ab6159b7f61ec57099c4b262b195459ba;hb=3c32ced9076b91fe2c44bcada22c97a37d564b78;hp=c46be839c3192529fa2c749c8dc2bbc224e9d52c;hpb=7894fbab1e479c2ce906aed9132b15a68bfa5d73;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/overload.pm b/lib/overload.pm index c46be83..ba96bc9 100644 --- a/lib/overload.pm +++ b/lib/overload.pm @@ -1,5 +1,7 @@ package overload; +$overload::hint_bits = 0x20000; + sub nil {} sub OVERLOAD { @@ -113,9 +115,9 @@ sub mycan { # Real can would leave stubs. %ops = ( with_assign => "+ - * / % ** << >> x .", assign => "+= -= *= /= %= **= <<= >>= x= .=", - str_comparison => "< <= > >= == !=", + num_comparison => "< <= > >= == !=", '3way_comparison'=> "<=> cmp", - num_comparison => "lt le gt ge eq ne", + str_comparison => "lt le gt ge eq ne", binary => "& | ^", unary => "neg ! ~", mutators => '++ --', @@ -129,7 +131,7 @@ sub constant { # Arguments: what, sub while (@_) { $^H{$_[0]} = $_[1]; - $^H |= $constants{$_[0]} | 0x20000; + $^H |= $constants{$_[0]} | $overload::hint_bits; shift, shift; } } @@ -396,9 +398,9 @@ A computer-readable form of the above table is available in the hash with_assign => '+ - * / % ** << >> x .', assign => '+= -= *= /= %= **= <<= >>= x= .=', - str_comparison => '< <= > >= == !=', + num_comparison => '< <= > >= == !=', '3way_comparison'=> '<=> cmp', - num_comparison => 'lt le gt ge eq ne', + str_comparison => 'lt le gt ge eq ne', binary => '& | ^', unary => 'neg ! ~', mutators => '++ --', @@ -1029,7 +1031,7 @@ circumscribed octagon using the above package: my $iter = 1; # 2**($iter+2) = 8 my $side = new symbolic 1; my $cnt = $iter; - + while ($cnt--) { $side = (sqrt(1 + $side**2) - 1)/$side; } @@ -1154,7 +1156,7 @@ Use this module like this: my $iter = new symbolic 2; # 16-gon my $side = new symbolic 1; my $cnt = $iter; - + while ($cnt) { $cnt = $cnt - 1; # Mutator `--' not implemented $side = (sqrt(1 + $side**2) - 1)/$side;