New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PATCH] document that range operator cannot be overloaded #12910
Comments
From @moritzHi all, attached patch documents some pitfalls wrt '..' not being overloadable I've tried to match bigint.pm's weird style of using initial tabs and Cheers, |
From @moritz0001-document-that-.-can-not-be-overloaded.patchFrom 3685d53313de808905a9d0940b19af7d0079f675 Mon Sep 17 00:00:00 2001
From: Moritz Lenz <moritz@faui2k3.org>
Date: Thu, 11 Apr 2013 15:06:32 +0200
Subject: [PATCH] document that .. can not be overloaded
Also document that this means that ranges and bigint.pm do not mix perfectly.
---
dist/bignum/lib/bigint.pm | 14 ++++++++++++++
lib/overload.pm | 4 ++++
2 files changed, 18 insertions(+)
diff --git a/dist/bignum/lib/bigint.pm b/dist/bignum/lib/bigint.pm
index 38aa7da..647cb29 100644
--- a/dist/bignum/lib/bigint.pm
+++ b/dist/bignum/lib/bigint.pm
@@ -608,6 +608,20 @@ This method only works on Perl v5.9.4 or later.
=over 2
+=item ranges
+
+Perl does not allow overloading of ranges, so you can neither safely use
+ranges with bigint endpoints, nor is the iterator variable a bigint.
+
+ use 5.010;
+ for my $i (12..13) {
+ for my $j (20..21) {
+ say $i ** $j; # produces a floating-point number,
+ # not a big integer
+ }
+ }
+
+
=item in_effect()
This method only works on Perl v5.9.4 or later.
diff --git a/lib/overload.pm b/lib/overload.pm
index ce339cd..66ca940 100644
--- a/lib/overload.pm
+++ b/lib/overload.pm
@@ -1675,6 +1675,10 @@ coincides with the current one.
Barewords are not covered by overloaded string constants.
+=item *
+
+The range operator C<..> cannot be overloaded.
+
=back
=cut
--
1.7.10.4
|
From @moritz... and another one; I didn't catch the omission in the first sentence |
From @moritz0001-bigint.pm-be-more-accurate-in-the-docs.patchFrom 885880792e6acc2853062aa549334f598cf6dc3c Mon Sep 17 00:00:00 2001
From: Moritz Lenz <moritz@faui2k3.org>
Date: Thu, 11 Apr 2013 15:17:04 +0200
Subject: [PATCH] [bigint.pm] be more accurate in the docs
---
dist/bignum/lib/bigint.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dist/bignum/lib/bigint.pm b/dist/bignum/lib/bigint.pm
index 647cb29..bb0ae69 100644
--- a/dist/bignum/lib/bigint.pm
+++ b/dist/bignum/lib/bigint.pm
@@ -328,8 +328,8 @@ bigint - Transparent BigInteger support for Perl
=head1 DESCRIPTION
-All operators (including basic math operations) are overloaded. Integer
-constants are created as proper BigInts.
+All operators (including basic math operations) except the range operator C<..>
+are overloaded. Integer constants are created as proper BigInts.
Floating point constants are truncated to integer. All parts and results of
expressions are also truncated.
--
1.7.10.4
|
From [Unknown Contact. See original ticket]... and another one; I didn't catch the omission in the first sentence |
@moritz - Status changed from 'new' to 'open' |
From @jkeenanOn Thu Apr 11 06:18:12 2013, moritz wrote:
Moritz, +1 on both patches; I tested the example in the first and observed that But since I'm not an expert on overloading or on bigint, I'd appreciate Thank you very much. |
From @rjbsLooks good. -- |
@jkeenan - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#117573 (status was 'resolved')
Searchable as RT117573$
The text was updated successfully, but these errors were encountered: