Open p5pRT opened 10 years ago
The fat comma operator (=>) doesn't seem to quote v-strings when used in the "use BLAH v1 => 42" lines. A particular example is "use constant v1 => 42" The v1 should be quoted by the => operator\, but that line of code produces a syntax error: "syntax error at -e line 1\, near "use constant v1 =>""
On Mon\, Jan 6\, 2014 at 5:50 PM\, Zoffix Znet \perlbug\-followup@​perl\.orgwrote:
The fat comma operator (=>) doesn't seem to quote v-strings when used in the "use BLAH v1 => 42" lines. A particular example is "use constant v1 => 42" The v1 should be quoted by the => operator\, but that line of code produces a syntax error: "syntax error at -e line 1\, near "use constant v1 =>""
use optionally takes a version\, so that is parsed as «use \
Leon
The RT System itself - Status changed from 'new' to 'open'
Leon Timmermans \fawaka@​gmail\.com writes:
use optionally takes a version\, so that is parsed as «use \
\ \ »\, and => is not a valid start of an expression.
The question is: is this desired (a.o.t. actual) behaviour\, or should
use constant v1 => 1;
DWIM?
-- Johan
On Tue\, Jan 7\, 2014 at 1:21 AM\, Johan Vromans \jvromans@​squirrel\.nl wrote:
Leon Timmermans \fawaka@​gmail\.com writes:
use optionally takes a version\, so that is parsed as «use \
\ \ »\, and => is not a valid start of an expression. The question is: is this desired (a.o.t. actual) behaviour\, or should
use constant v1 => 1;
DWIM?
I would expect that to be the equivalent to `use constant ('v1'\,1)` It is definitely being parsed as the version part of the `use` statement because it works if you place it in parens `use constant (v1 => 1)`
Although it makes it more difficult to create a v-string with a single element of ordinal 1.
perl -MDevel::Peek -E'use constant "v1" => 2;$v= v1;say Dump $v'
perl -MDevel::Peek -E'use constant "v1" => 2;$v= v01;say Dump $v' perl -MDevel::Peek -E'use constant "v1" => 2;$v= do{package clean;v1};say Dump $v'
So creating a subroutine matching `/\Av[0-9]+\z/` should probably be discouraged. Maybe even going so far as having `constant` warn if you ask it to create a constant with a matching name.
( Further discussion of having constant warn\, or adding a discouragement to the docs should be brought up in a new thread )
Brad Gilbert \b2gills@​gmail\.com writes:
I would expect that to be the equivalent to `use constant ('v1'\,1)`
Yes\, but the syntax of 'use' is (perdoc -f):
use Module VERSION LIST
and not
use Module VERSION \, LIST
(note the comma).
So in
use Module X\,Y\,Z;
X\,Y\,Z is the LIST part\, even if X resembles a version number. The correct invocation for the latter is
use Module X Y\,Z;
-- Johan
On Mon Jan 06 23:21:34 2014\, jv wrote:
Leon Timmermans \fawaka@​gmail\.com writes:
use optionally takes a version\, so that is parsed as «use \
\ \ »\, and => is not a valid start of an expression. The question is: is this desired (a.o.t. actual) behaviour\, or should
use constant v1 => 1;
DWIM?
Probably\, especially considering that this dwims:
use constant v1=> 1;
--
Father Chrysostomos
On 7 January 2014 22:04\, Johan Vromans \jvromans@​squirrel\.nl wrote:
Yes\, but the syntax of 'use' is (perdoc -f):
use Module VERSION LIST
and not
use Module VERSION \, LIST
(note the comma).
Indeed\, seems obvious given that criteria that
use Module 1\, 2; # Valid\, passes [ 1\, 2 ]
and
use Module 1 => 2; # Syntax error
it seems they'd aught to parse the same way. Just they don't.
use v5.18; use warnings; use utf8;
BEGIN { package TestClass;
our $VERSION = 9999;
use Data::Dump qw(pp);
sub import { my ( $self\, @args ) = @_; pp \@args; 1; } $INC{'TestClass.pm'} = 1; }
my @code = ( q[use TestClass 1 => 2]\, q[use TestClass v1 => 2]\, q[use TestClass 1 2]\, q[use TestClass v1 2]\,
q[use TestClass 1\, 2]\, q[use TestClass v1\, 2]\,
q[use TestClass ( 1 => 2 )]\, q[use TestClass ( v1 => 2 )]\,
);
for my $code ( @code ) { say '--'; say "$code"; eval $code or say $@; }
__[ output ]__
-- use TestClass 1 => 2 syntax error at (eval 1) line 1\, near "use TestClass 1 =>"
-- use TestClass v1 => 2 syntax error at (eval 2) line 1\, near "use TestClass v1 =>"
-- use TestClass 1 2 [2]
-- use TestClass v1 2 [2]
-- use TestClass 1\, 2 [1\, 2]
-- use TestClass v1\, 2 [v1\, 2]
-- use TestClass ( 1 => 2 ) [1\, 2]
-- use TestClass ( v1 => 2 ) ["v1"\, 2]
-- Kent \<http://kent-fredric.fox.geek.nz>
On Tue\, Jan 7\, 2014 at 3:04 AM\, Johan Vromans \jvromans@​squirrel\.nl wrote:
Brad Gilbert \b2gills@​gmail\.com writes:
I would expect that to be the equivalent to `use constant ('v1'\,1)`
Yes\, but the syntax of 'use' is (perdoc -f):
use Module VERSION LIST
and not
use Module VERSION \, LIST
(note the comma).
So in
use Module X\,Y\,Z;
X\,Y\,Z is the LIST part\, even if X resembles a version number. The correct invocation for the latter is
use Module X Y\,Z;
I said it is being parsed as the version part\, not that is what I expected. What I meant was that I expected it to be essentially the same as:
use constant; sub v1(){1}
That is I would have expected it to be parsed as the first item in the list\, not the minimum version.
Which is why I also said it would make it difficult to create a v-string with a single element of ordinal 1.
I agree with the general consensus that this is a bug.
-- rjbs
I agree with the general consensus that this is a bug.
-- rjbs
Migrated from rt.perl.org#120941 (status was 'open')
Searchable as RT120941$