Skip to content

Commit 42ad323

Browse files
committed
remove space between sub/method names and opening paren
1 parent af0228e commit 42ad323

26 files changed

+74
-73
lines changed

doc/Language/5to6-nutshell.pod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ designed to be more concise in concepts than in keystrokes.
9797
9898
As a result, there are various places in the syntax where whitespace is
9999
optional in Perl 5, but is either mandatory or forbidden in Perl 6. Many of
100-
those restrictions are unlikely to concern much real-life Perl code (e.g.
100+
those restrictions are unlikely to concern much real-life Perl code (e.g.,
101101
whitespace being disallowed between the sigil and name of a variable), but
102102
there are a few that will unfortunately conflict with some Perl hackers'
103103
habitual coding styles:
@@ -602,15 +602,15 @@ expect Pairs. However, this requires you to change all sub calls at once.
602602
# Note: no curly braces in this sub call
603603
get_the_loot( 'diamonds', quiet_level => 'very', quantity => 9 );
604604
# Perl 6, original API
605-
sub get_the_loot ( $loot, *%options ) { # The * means to slurp everything
605+
sub get_the_loot( $loot, *%options ) { # The * means to slurp everything
606606
...
607607
}
608608
get_the_loot( 'diamonds', quiet_level => 'very', quantity => 9 ); # Note: no curly braces in this API
609609
610610
# Perl 6, API changed to specify valid options
611611
# The colon before the sigils means to expect a Pair,
612612
# with the key having the same name as the variable.
613-
sub get_the_loot ( $loot, :$quiet_level?, :$quantity = 1 ) {
613+
sub get_the_loot( $loot, :$quiet_level?, :$quantity = 1 ) {
614614
# This version will check for unexpected arguments!
615615
...
616616
}
@@ -1117,7 +1117,7 @@ Switch parsing is now done by the parameter list of the C<MAIN> subroutine.
11171117
5
11181118
11191119
# Perl 6
1120-
sub MAIN ( Int :$xyz ) {
1120+
sub MAIN( Int :$xyz ) {
11211121
say $xyz if $xyz.defined;
11221122
}
11231123
perl6 example.p6 --xyz=5
@@ -1436,7 +1436,7 @@ Switch parsing is now done by the parameter list of the C<MAIN> subroutine.
14361436
Died at c.pl line 3.
14371437
14381438
# Perl 6
1439-
sub MAIN ( Int :$length = 24, :file($data) = 'file.dat', Bool :$verbose ) {
1439+
sub MAIN( Int :$length = 24, :file($data) = 'file.dat', Bool :$verbose ) {
14401440
say $length if $length.defined;
14411441
say $data if $data.defined;
14421442
say 'Verbosity ', ($verbose ?? 'on' !! 'off');

doc/Language/5to6-perlfunc.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,11 +1453,11 @@ C<study> is no more.
14531453
14541454
=item sub NAME BLOCK
14551455
1456-
=item sub NAME (PROTO) BLOCK
1456+
=item sub NAME(PROTO) BLOCK
14571457
14581458
=item sub NAME : ATTRS BLOCK
14591459
1460-
=item sub NAME (PROTO) : ATTRS BLOCK
1460+
=item sub NAME(PROTO) : ATTRS BLOCK
14611461
14621462
Unsurprisingly, we still have subroutines! You can have a signature in
14631463
your subroutine which allows you to specify arguments. Nevertheless, in

doc/Language/faq.pod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Example:
153153
154154
say 1/0 # Attempt to divide 1 by zero using div
155155
156-
sub foo ( Int $a, Int $b ) {...}
156+
sub foo( Int $a, Int $b ) {...}
157157
foo(1) # ===SORRY!=== Error while compiling ...
158158
159159
=head2 What is C<(Any)>?

doc/Language/functions.pod

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ C<sub foo {...}> is the same as C<my sub foo {...}> and is only
4343
defined within the current scope.
4444
4545
=begin code :allow<L>
46-
sub escape ($str) {
46+
sub escape($str) {
4747
# Puts a slash before non-alphanumeric characters
4848
S:g[<-alpha -digit>] = "\\$/" given $str
4949
}
5050
5151
say escape 'foo#bar?'; # foo\#bar\?
5252
5353
{
54-
sub escape ($str) {
54+
sub escape($str) {
5555
# Writes each non-alphanumeric character in its hexadecimal escape
5656
S:g[<-alpha -digit>] = "\\x[{ $/.ord.base(16) }]" given $str
5757
}
@@ -259,12 +259,12 @@ be broken out element-by-element using a **@ slurpy, with two nuances:
259259
260260
This can be achieved by using a slurpy with a C<+> or C<+@> instead of C<**>:
261261
262-
sub grab (+@a) { "grab $_".say for @a }
262+
sub grab(+@a) { "grab $_".say for @a }
263263
264264
...which is shorthand for something very close to:
265265
266-
multi sub grab (**@a) { "grab $_".say for @a }
267-
multi sub grab (\a) {
266+
multi sub grab(**@a) { "grab $_".say for @a }
267+
multi sub grab(\a) {
268268
a ~~ Iterable and a.VAR !~~ Scalar ?? nextwith(|a) !! nextwith(a,)
269269
}
270270
@@ -286,14 +286,15 @@ one sublist, or many:
286286
287287
It is worth noting that mixing binding and sigilless variables
288288
in these cases requires a bit of finesse, because there is no Scalar
289-
intermediary used during binding.
289+
intermediary used during binding. (Notice the space before the opening '('
290+
which is normally not a good practice.)
290291
291292
my $a = (1, 2); # Normal assignment, equivalent to $(1, 2)
292-
grab ($a); # grab 1 2
293+
grab($a); # grab 1 2
293294
my $b := (1, 2); # Binding, $b links directly to a bare (1, 2)
294-
grab ($b); # grab 1 grab 2
295+
grab($b); # grab 1 grab 2
295296
my \c = (1, 2); # Sigilless variables always bind, even with '='
296-
grab (c); # grab 1 grab 2
297+
grab(c); # grab 1 grab 2
297298
298299
=head1 Functions are First-Class Objects
299300
@@ -313,7 +314,7 @@ Or you can reference an existing named function by using the C<&> in front of
313314
it.
314315
315316
=begin code
316-
sub square ($x) { $x * $x };
317+
sub square($x) { $x * $x };
317318
318319
# get hold of a reference to the function:
319320
my $func = &square
@@ -323,7 +324,7 @@ This is very useful for I<higher order functions>, that is, functions that
323324
take other functions as input. A simple one is L<map|/type/List#routine_map>,
324325
which applies a function to each input element:
325326
326-
sub square ($x) { $x * $x };
327+
sub square($x) { $x * $x };
327328
my @squared = map &square, 1..5;
328329
say join ', ', @squared; # 1, 4, 9, 16, 25
329330
@@ -757,7 +758,7 @@ and its signature is the means by which command line arguments can be parsed.
757758
Multi methods are supported and a usage method is automatically generated and
758759
displayed if no command line arguments are provided.
759760
760-
sub MAIN ( Int :$length = 24,
761+
sub MAIN( Int :$length = 24,
761762
:file($data) where { .IO.f // die "file not found in $*CWD" } = 'file.dat',
762763
Bool :$verbose )
763764
{

doc/Language/modules.pod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ As with all traits, if applied to a routine, "is export" should appear after
132132
any argument list.
133133
134134
=begin code
135-
sub foo (Str $string) is export { ... }
135+
sub foo(Str $string) is export { ... }
136136
=end code
137137
138138
You can pass named parameters to C<is export> to group symbols for exporting

doc/Language/objects.pod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ C<Automobile>, for things that you can drive.
599599
}
600600
class Automobile {
601601
has $.direction;
602-
method steer ($!direction) { }
602+
method steer($!direction) { }
603603
}
604604
class Taurus is Bull is Automobile { }
605605
@@ -620,7 +620,7 @@ case, it may have been better to use roles:
620620
}
621621
role Steerable {
622622
has Real $.direction;
623-
method steer (Real $d = 0) {
623+
method steer(Real $d = 0) {
624624
$!direction += $d;
625625
}
626626
}
@@ -636,7 +636,7 @@ This check will save you and your customers a lot of headaches and you can
636636
simply define your class instead as:
637637
638638
class Taurus does Bull-Like does Steerable {
639-
method steer ($direction?) {
639+
method steer($direction?) {
640640
self.Steerable::steer($direction?)
641641
}
642642
}
@@ -819,8 +819,8 @@ Mixins can happen at any time of your object's life.
819819
# A counter for Table of Contents
820820
role TOC-Counter {
821821
has Int @!counters is default(0);
822-
method Str () { @!counters.join: '.' }
823-
method inc ($level) {
822+
method Str() { @!counters.join: '.' }
823+
method inc($level) {
824824
@!counters[$level - 1]++;
825825
@!counters.splice($level);
826826
self

doc/Language/performance.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ L<camelia|/glossary#camelia>.
9393
With multidispatch you can drop in new variants of routines "alongside" existing ones:
9494
9595
# existing code generically matches a two arg foo call:
96-
multi sub foo (Any $a, Any $b) { ... }
96+
multi sub foo(Any $a, Any $b) { ... }
9797
9898
# new variant takes over for a foo("quux", 42) call:
99-
multi sub foo ("quux", Int $b) { ... }
99+
multi sub foo("quux", Int $b) { ... }
100100
101101
The call overhead of having multiple C<foo> definitions is generally insignificant (though see discussion
102102
of C<where> below), so if your new definition handles its particular case more quickly/leanly than the

doc/Language/subscripts.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ separately like this:
630630
method AT-KEY ($key) is rw { %!fields{normalize-key $key} }
631631
method EXISTS-KEY ($key) { %!fields{normalize-key $key}:exists }
632632
method DELETE-KEY ($key) { %!fields{normalize-key $key}:delete }
633-
method push (*@_) { #`[not shown, for brevity] }
633+
method push(*@_) { #`[not shown, for brevity] }
634634
635635
sub normalize-key ($key) { $key.subst(/\w+/, *.tc, :g) }
636636
@@ -671,7 +671,7 @@ others as detailed below.
671671
672672
=head3 method elems
673673
674-
multi method elems (::?CLASS:D:)
674+
multi method elems(::?CLASS:D:)
675675
676676
Expected to return a number indicating how many subscriptable elements
677677
there are in the object. May be called by users directly, and is also

doc/Language/traps.pod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ last element of an array becomes:
177177
178178
Quite often new users will happen to write something like:
179179
180-
sub foo (Array @a) { ... }
180+
sub foo(Array @a) { ... }
181181
182182
...before they have gotten far enough in the documentation to realize that
183183
this is asking for an Array of Arrays. To say that C<@a> should only accept

doc/Language/variables.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The default type can be set with C<is>.
3939
callsame
4040
}
4141
42-
method finalize () {
42+
method finalize() {
4343
$!final = True
4444
}
4545
}
@@ -592,7 +592,7 @@ be omitted.
592592
Please note that many operators come with implicit binding, what will lead to actions at a distance. Use C<.clone> or coercion to create a new container that can be bound to.
593593
594594
my @a;
595-
sub f () {
595+
sub f() {
596596
state $i;
597597
$i++;
598598
@a.push: "k$i" => $i # <-- .clone goes here

0 commit comments

Comments
 (0)