develooper Front page | perl.perl5.porters | Postings from October 2008

Re: Why are "Scalar value better written as" warnings not thrown for arrayrefs?

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
October 31, 2008 06:13
Subject:
Re: Why are "Scalar value better written as" warnings not thrown for arrayrefs?
Message ID:
b77c1dce0810310613k49360aa0g48a5a6f011795463@mail.gmail.com
2008/10/31 Chas. Owens <chas.owens@gmail.com>:
> I noticed today that no warning is thrown when a reference is used in
> a slice of one element, is there a reason for this?  I tested with
> both 5.8.8 and 5.10.0.

Because in the @a[0] case, the tokenizer is able to see the whole @a
expression, and check some heuristics to throw the warning, while in
the @{$ref}[0] case, the parser is called to parse what's in the
braces.

As many syntax warnings, they're only heuristics.

Example of another way to fool the warning: @a[q/0/].

-- 
#11953 Bien sûr, ce n'est qu'une heuristique, ce qui veut dire plus
prosaïquement que ça ne marche pas.

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