Skip to content
This repository

Clarify when prefix<::> can be used as in-place predeclarator #10

Merged
merged 5 commits into from over 1 year ago

2 participants

skids Konrad Borowski
skids

skids hrm.
rakudo: class A { multi method foo(::B $b) { say "Surprise! ::B is an en-passant type capture"; } }; class B { }; my B $b .= new(); my A $a .= new(); $a.foo($b); $a.foo(2);
p6eval rakudo 38165a: OUTPUT«Surprise! ::B is an en-passant type capture␤Surprise! ::B is an en-passant type capture␤»
PerlJam skids: why is that a surprise exactly?
skids It's a surprise to anyone who thought they were using ::B to use a class before it was declared.
(which is something they will probably learn well before learning what an en-passant type capture is)
jnthn skids: The rule is that ::B only works for talking about as yet undeclared types in non-declarative scenarios. A signature is declarative.

Konrad Borowski xfix merged commit fc0e3bd into from December 01, 2012
Konrad Borowski xfix closed this December 01, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
4  S06-routines.pod
Source Rendered
@@ -804,13 +804,13 @@ order of arguments with the same name.  When there are more than one
804 804
 argument, the C<@> sigil in the parameter list causes the arguments
805 805
 to be concatenated:
806 806
 
807  
-    sub fun (Int @x) { ... }
  807
+    sub fun (Int :@x) { ... }
808 808
     fun( x => 1, x => 2 );              # @x := (1, 2)
809 809
     fun( x => (1, 2), x => (3, 4) );    # @x := (1, 2, 3, 4)
810 810
 
811 811
 Other sigils bind only to the I<last> argument with that name:
812 812
 
813  
-    sub fun (Int $x) { ... }
  813
+    sub fun (Int :$x) { ... }
814 814
     fun( x => 1, x => 2 );              # $x := 2
815 815
     fun( x => (1, 2), x => (3, 4) );    # $x := (3, 4)
816 816
 
10  S10-packages.pod
Source Rendered
@@ -46,10 +46,12 @@ the file is Perl 5 code.
46 46
 This form is illegal in a Perl 6 file.  If you wish to have a file-scoped package,
47 47
 either use the brace form or declare it with the C<module> keyword instead.
48 48
 
49  
-Since there are no barewords in Perl 6, package names must be predeclared,
50  
-or use the sigil-like C<::PackageName> syntax to indicate that the type will
51  
-be supplied some other way.  The C<::> prefix does not imply globalness as
52  
-it does in Perl 5.  (Use C<GLOBAL::> for that.)
  49
+Since there are no barewords in Perl 6, package names must be predeclared.
  50
+Alternatively, the sigil-like C<::PackageName> syntax may be used to indicate
  51
+that the type will be supplied some other way, however this syntax is not valid
  52
+in declarative scenarios, especially parameter lists where it has entirely
  53
+different semantics.  The C<::> prefix does not imply globalness as it does in
  54
+Perl 5.  (Use C<GLOBAL::> for that.)
53 55
 
54 56
 A bare C<package> declarator (without an explicit scope declarator
55 57
 such as C<my>) declares an C<our> package within the current package
2  S12-objects.pod
Source Rendered
@@ -1847,7 +1847,7 @@ Such declarational forms are not always convenient; to translate
1847 1847
 native enum values back to their names operationally, you can pull
1848 1848
 out the enum type's C<EnumMap> and invert it:
1849 1849
 
1850  
-    constant %dayname := Day.enums.invert;
  1850
+    constant %dayname := day.enums.invert;
1851 1851
     %dayname{3} # Wed
1852 1852
 
1853 1853
 =head2 The Enumeration Type
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.