From 7fb26aef67f2552df5647acb7db9f746ede7605b Mon Sep 17 00:00:00 2001 From: Felix Herrmann Date: Tue, 12 Jun 2012 15:31:57 +0200 Subject: [PATCH] introduce X::Numeric::Real Signed-off-by: Moritz Lenz --- S32-setting-library/Exception.pod | 14 ++++++++++++++ S32-setting-library/Numeric.pod | 10 ++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/S32-setting-library/Exception.pod b/S32-setting-library/Exception.pod index 736136bec..ef5f8adf1 100644 --- a/S32-setting-library/Exception.pod +++ b/S32-setting-library/Exception.pod @@ -1235,6 +1235,20 @@ not know how to handle. } } +=head2 X::Numeric::Real + +Occurs when an attempt to coerce a C to a C, C, C or +C fails (due to a number with a nonzero imaginary part, for instance). + + my class X::Numeric::Real is Exception { + has $.target; + has $.reason; + + method message() { + "Can not convert Numeric to {$.target.^name}: $.reason"; + } + } + =head1 Related types =head2 Failure diff --git a/S32-setting-library/Numeric.pod b/S32-setting-library/Numeric.pod index 44afb7095..17f48673b 100644 --- a/S32-setting-library/Numeric.pod +++ b/S32-setting-library/Numeric.pod @@ -85,28 +85,30 @@ mathematical functions. If this C is equivalent to a C, return that C. (For instance, if this number is a C with a zero imaginary part.) -Fail otherwise. +Fail with C otherwise. =item Int multi method Int ( --> Int ) If this C is equivalent to a C, return the equivalent of -calling C on that C to get an C. +calling C on that C to get an C. Fail with +C otherwise. =item Rat multi method Rat ( Real $epsilon = 1.0e-6 --> Rat ) If this C is equivalent to a C, return a C which is -within C<$epsilon> of that C's value. +within C<$epsilon> of that C's value. Fail with C +otherwise. =item Num multi method Num ( --> Num ) If this C is equivalent to a C, return that C as a C -as accurately as is possible. +as accurately as is possible. Fail with C otherwise. =item succ