Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 5 commits into from

2 participants

@skids
Collaborator

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.

@xfix xfix merged commit fc0e3bd into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 10, 2012
Commits on Jan 28, 2012
  1. Merge branch 'update'

    bri authored
Commits on Feb 12, 2012
  1. @skids
  2. @skids
Commits on Feb 14, 2012
  1. @skids
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 7 deletions.
  1. +2 −2 S06-routines.pod
  2. +6 −4 S10-packages.pod
  3. +1 −1  S12-objects.pod
View
4 S06-routines.pod
@@ -804,13 +804,13 @@ order of arguments with the same name. When there are more than one
argument, the C<@> sigil in the parameter list causes the arguments
to be concatenated:
- sub fun (Int @x) { ... }
+ sub fun (Int :@x) { ... }
fun( x => 1, x => 2 ); # @x := (1, 2)
fun( x => (1, 2), x => (3, 4) ); # @x := (1, 2, 3, 4)
Other sigils bind only to the I<last> argument with that name:
- sub fun (Int $x) { ... }
+ sub fun (Int :$x) { ... }
fun( x => 1, x => 2 ); # $x := 2
fun( x => (1, 2), x => (3, 4) ); # $x := (3, 4)
View
10 S10-packages.pod
@@ -46,10 +46,12 @@ the file is Perl 5 code.
This form is illegal in a Perl 6 file. If you wish to have a file-scoped package,
either use the brace form or declare it with the C<module> keyword instead.
-Since there are no barewords in Perl 6, package names must be predeclared,
-or use the sigil-like C<::PackageName> syntax to indicate that the type will
-be supplied some other way. The C<::> prefix does not imply globalness as
-it does in Perl 5. (Use C<GLOBAL::> for that.)
+Since there are no barewords in Perl 6, package names must be predeclared.
+Alternatively, the sigil-like C<::PackageName> syntax may be used to indicate
+that the type will be supplied some other way, however this syntax is not valid
+in declarative scenarios, especially parameter lists where it has entirely
+different semantics. The C<::> prefix does not imply globalness as it does in
+Perl 5. (Use C<GLOBAL::> for that.)
A bare C<package> declarator (without an explicit scope declarator
such as C<my>) declares an C<our> package within the current package
View
2  S12-objects.pod
@@ -1847,7 +1847,7 @@ Such declarational forms are not always convenient; to translate
native enum values back to their names operationally, you can pull
out the enum type's C<EnumMap> and invert it:
- constant %dayname := Day.enums.invert;
+ constant %dayname := day.enums.invert;
%dayname{3} # Wed
=head2 The Enumeration Type
Something went wrong with that request. Please try again.