develooper Front page | perl.perl5.porters | Postings from August 2016

Re: Not sure if this is a bug or not: Ranges and integer arithmetic

Thread Previous | Thread Next
From:
korg
Date:
August 31, 2016 21:43
Subject:
Re: Not sure if this is a bug or not: Ranges and integer arithmetic
Message ID:
65e6315fb18dfe55794bcb2a74825deb@tune-it.ru
Such strange behavior of "~" operator (implicit signed integer context) 
seems to be also in slices and array indexes:

$ perl -le '@arr=1..5; print @arr[~1], $arr[~1]'
44

Kind regards,
Sergey Zhmylove.


31.08.2016 3:58, Father Chrysostomos wrote:
> Matt S Trout wrote:
>> THis seems inconsistent at best, but I wasn't sure exactly what to 
>> report.
> It is inconsistent.  I think it is a bug.  But deciding how it should
> behave is the hard part.  Can we change it without breaking peo-
> ple's code?
> 
> I suppose the way to change it without breaking people's code is to
> make foreach match the dotty behaviour.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About