Front page | perl.perl5.porters |
Postings from August 2016
Not sure if this is a bug or not: Ranges and integer arithmetic
Thread Next
From:
Matt S Trout
Date:
August 30, 2016 21:20
Subject:
Not sure if this is a bug or not: Ranges and integer arithmetic
Message ID:
20160830212032.GI22736@newagaton.scsys.co.uk
22:01 < zhmylove> eval: print join ",",((~12)..-1)
22:01 < perlbot> zhmylove: -13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1
22:04 < mst> eval: push @x, $_ for ((~12)..1); \@x
22:04 < perlbot> mst: ERROR: Range iterator outside integer range at (eval 538)
line 1, <STDIN> line 1.
22:05 < mst> eval: push @x, $_ for @{[(~12)..-1]}; \@x
22:05 < perlbot> mst: [-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1]
22:13 < mst> eval: use integer; push @x, $_ for ~12..-1; \@x
22:13 < perlbot> mst: [-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1]
So it seems that range-expansion-in-place uses 'use integer' semantics,
whereas when it remains unexpanded (I guess because foreach can traverse
the range without needing a list at all) it isn't.
THis seems inconsistent at best, but I wasn't sure exactly what to report.
--
Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a clue
http://shadowcat.co.uk/blog/matt-s-trout/ http://twitter.com/shadowcat_mst/
Email me now on mst (at) shadowcat.co.uk and let's chat about how our CPAN
commercial support, training and consultancy packages could help your team.
Thread Next
-
Not sure if this is a bug or not: Ranges and integer arithmetic
by Matt S Trout