Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I name a sigilless variable v+digit?

Running the following simple code, checking the behaviour of sigilless variables, produces a strange error:

use v6.d;  # Rakudo Star 2020.05.01 (Windows)

sub test ($p) {
    say $p;
}

my \v1 = 1;

say v1;   # v1 (ERROR)
test(v1); # v1 (ERROR)

my \v = 1;

say v;   # 1 (Correct)
test(v); # 1 (Correct)

my \vv1 = 1;

say vv1;   # 1 (Correct)
test(vv1); # 1 (Correct)

my \s1 = 1;

say s1;   # 1 (Correct)
test(s1); # 1 (Correct)

Why is that?

like image 568
jakar Avatar asked Sep 20 '20 08:09

jakar


1 Answers

Literals that start with v and are followed by a number (and dots and then other numbers) are considered versions. That means that you can't use anything starting with v and followed by numbers as sigilless identifier.

say (v1.2.3).parts; # OUTPUT: «(1 2 3)␤» 

That's probably underdocumented, though...

like image 106
jjmerelo Avatar answered Oct 18 '22 04:10

jjmerelo