Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
5to6: move method call section to the top
  • Loading branch information
smls committed Feb 23, 2015
1 parent 5c54e6c commit a42f276
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/Language/5to6.pod
Expand Up @@ -44,6 +44,26 @@ promising.
=head2 Syntax
=head3 C«->» Method calls
If you've read any Perl 6 code at all, it's immediately obvious that
method call syntax now uses a dot instead of an arrow:
$person->name # Perl 5
$person.name # Perl 6
The dot notation is both easier to type and more of an industry standard.
But we also wanted to steal the arrow for something else. (Concatenation
is now done with the C<~> operator, if you were wondering.)
To call a method whose name is not known until runtime:
$object->$methodname(@args); # Perl 5
$object."$methodname"(@args); # Perl 6
If you leave out the quotes, then Perl 6 expects C<$methodname> to contain
a C<Method> object, rather than the simple string name of the method.
=head3 Whitespace
Perl 5 allows a surprising amount of flexibility in the use of whitespace,
Expand Down Expand Up @@ -283,26 +303,6 @@ And here's just one possible Perl 6 translation:
my $in-file = open $path or die;
my ($line1, $line2) = read-n($in-file, 2);
=head3 C«->» Method calls
If you've read any Perl 6 code at all, it's immediately obvious that
method call syntax now uses a dot instead of an arrow:
$person->name # Perl 5
$person.name # Perl 6
The dot notation is both easier to type and more of an industry standard.
But we also wanted to steal the arrow for something else. (Concatenation
is now done with the C<~> operator, if you were wondering.)
To call a method whose name is not known until runtime:
$object->$methodname(@args); # Perl 5
$object."$methodname"(@args); # Perl 6
If you leave out the quotes, then Perl 6 expects C<$methodname> to contain
a C<Method> object, rather than the simple string name of the method.
=head3 Reference creation
=comment TODO: Rewrite this section to make it clear that the "referencing/
Expand Down

0 comments on commit a42f276

Please sign in to comment.