https://github.com/froggs/p6-overload-constant
https://github.com/froggs/p6-overload-constant
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/froggs/p6-overload-constant
- Owner: FROGGS
- Created: 2014-11-16T21:42:28.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-08-18T18:53:18.000Z (almost 9 years ago)
- Last Synced: 2025-02-15T13:48:28.796Z (over 1 year ago)
- Language: Perl 6
- Size: 5.86 KB
- Stars: 2
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## overload::constant
It is meant to work a bit like P5's overload::constant[1], though it is kind of pre-alpha here.
## USAGE
```perl6
sub integer { "i$^a" }
sub decimal { "d$^a" }
sub radix { "r$^a" }
sub numish { "n$^a" }
use overload::constant &integer, &decimal, &radix, &numish;
ok 42 ~~ Str && 42 eq 'i42', 'can overload integer';
ok 0.12 ~~ Str && 0.12 eq 'd0.12', 'can overload decimal';
ok .1e-003 ~~ Str && .1e-003 eq 'd.1e-003', 'can overload decimal in scientific notation';
ok :16 ~~ Str && :16 eq 'r:16', 'can overload radix';
ok NaN ~~ Str && NaN eq 'nNaN', 'can overload other numish things';
```
[1] http://perldoc.perl.org/overload.html#Overloading-Constants