Skip to content

Commit d1124cf

Browse files
committed
s/currying/priming/
Currying really means treating multi-arg functions as compositions of single-arg functions, so we should avoid misusing it the way most other people misuse it. :)
1 parent 2448d23 commit d1124cf

File tree

6 files changed

+28
-27
lines changed

6 files changed

+28
-27
lines changed

S02-bits.pod

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ and never as
984984
The C<*> character as a standalone term captures the notion of "Whatever",
985985
the meaning of which can be decided lazily by whatever it is an argument to.
986986
Alternately, for those unary and binary operators that don't care to handle
987-
C<*> themselves, it is automatically curried at compile time into a closure
987+
C<*> themselves, it is automatically primed at compile time into a closure
988988
that takes one or two arguments. (See below.)
989989

990990
Generally, when an operator handles C<*> itself, it can often
@@ -1016,19 +1016,20 @@ by marking the proto sub with the trait, C<is like-Whatever-and-stuff>.
10161016
[Conjecture: actually, this is negotiable--we might shorten it
10171017
to C<is like(Whatever)> or some such. C<:-)>]
10181018

1019-
=head3 Currying of Unary and Binary Operators
1019+
=head3 Priming of Unary and Binary Operators with Whatever
10201020

10211021
For any unary or binary operator (specifically, any prefix, postfix,
10221022
and infix operator), if the operator has not specifically requested
10231023
to handle C<*> itself, the compiler is required to translate directly
1024-
to an appropriately curried closure at compile time. Most of the
1024+
to an appropriately primed closure at compile time. (I<Priming> is our
1025+
term for partial function application.) Most of the
10251026
built-in numeric operators fall into this category, so:
10261027

10271028
* - 1
10281029
'.' x *
10291030
* + *
10301031

1031-
are internally curried into closures of one or two arguments:
1032+
are internally primed into closures of one or two arguments:
10321033

10331034
{ $^x - 1 }
10341035
{ '.' x $^y }
@@ -1040,30 +1041,30 @@ with the result that
10401041

10411042
* + (state $s = 0)
10421043

1043-
is effectively curried into:
1044+
is effectively primed into:
10441045

10451046
-> $x { $x + (state $OUTER::s = 0) }
10461047

10471048
rather than:
10481049

10491050
-> $x { $x + (state $s = 0) }
10501051

1051-
In other words, C<*> currying does not create a useful lexical scope.
1052+
In other words, C<*> priming does not create a useful lexical scope.
10521053
(Though it does have a dynamic scope when it runs.) This prevents the
10531054
semantics from changing drastically if the operator in question
10541055
suddenly decides to handle C<Whatever> itself.
10551056

10561057
As a postfix operator, a method call is one of those operators that is
1057-
automatically curried. Something like:
1058+
automatically primed. Something like:
10581059

10591060
*.meth(1,2,3)
10601061

10611062
is rewritten as:
10621063

10631064
{ $^x.meth(1,2,3) }
10641065

1065-
In addition to currying a method call without an invocant, such
1066-
curried methods are handy anywhere a smartmatcher is expected:
1066+
In addition to priming a method call without an invocant, such
1067+
primed methods are handy anywhere a smartmatcher is expected:
10671068

10681069
@primes = grep *.prime, 2..*;
10691070
subset Duck where *.^can('quack');
@@ -1081,9 +1082,9 @@ or its derivative closures can distinguish them by type:
10811082
0, 1, *+1 ... * # counting
10821083
0, 1, *+* ... * # fibonacci
10831084

1084-
For any prefix, postfix, or infix operator that would be curried by a
1085-
C<Whatever>, a C<WhateverCode> also autocurries it, such that any noun
1086-
phrase based on C<*> as a head noun autocurries transitively outward as
1085+
For any prefix, postfix, or infix operator that would be primed by a
1086+
C<Whatever>, a C<WhateverCode> also autoprimes it, such that any noun
1087+
phrase based on C<*> as a head noun autoprimes transitively outward as
10871088
far as it makes sense, including outward through metaoperators. Hence:
10881089

10891090
* + 2 + 3 # { $^x + 2 + 3 }
@@ -1097,12 +1098,12 @@ far as it makes sense, including outward through metaoperators. Hence:
10971098
This is only for operators that are not C<Whatever>-aware. There is no requirement
10981099
that a C<Whatever>-aware operator return a C<WhateverCode> when C<Whatever>
10991100
is used as an argument; that's just the I<typical> behavior for functions
1100-
that have no intrinsic "globbish" meaning for C<*>. If you want to curry
1101+
that have no intrinsic "globbish" meaning for C<*>. If you want to prime
11011102
one of these globbish operators, you'll need to write an explicit closure or do
1102-
an explicit curry on the operator with C<.assuming()>. Operators in
1103+
an explicit prime on the operator with C<.assuming()>. Operators in
11031104
this class, such as C<< infix:<..> >> and C<< infix:<xx> >>, typically I<do>
1104-
autocurry arguments of type C<WhateverCode> even though they do not
1105-
autocurry C<Whatever>, so we have:
1105+
autoprime arguments of type C<WhateverCode> even though they do not
1106+
autoprime C<Whatever>, so we have:
11061107

11071108
"foo" xx * # infinite supply of "foo"
11081109
"foo" xx *-1 # { "foo" xx $^a - 1 }
@@ -1125,13 +1126,13 @@ Operators that are known to return non-closure values with C<*> include:
11251126
$a = * # just assigns Whatever
11261127
$a ~~ * # just matches Whatever
11271128

1128-
Note that the last two also do not autocurry C<WhateverCode>, because
1129+
Note that the last two also do not autoprime C<WhateverCode>, because
11291130
assignment and smartmatching are not really normal binary operators, but
11301131
syntactic sugar for underlying primitives. (Such pseudo operators
11311132
may also place restrictions on which meta-operators work on them.)
11321133

11331134
Neither do the sequence operators C<< &infix:<...> >> and
1134-
C<< &infix:<...^> >> autocurry C<WhateverCode>, because we want to allow
1135+
C<< &infix:<...^> >> autoprime C<WhateverCode>, because we want to allow
11351136
WhateverCode closures as the stopper:
11361137

11371138
0 ...^ *>5 # means 0, 1, 2, 3, 4, 5

S03-operators.pod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3406,7 +3406,7 @@ to be intended as numeric if the left argument is numeric:
34063406
0 ..^ +@x # same thing
34073407

34083408
C<Whatever> types are also supported to represent -Inf/+Inf. If
3409-
either endpoint is a C<WhateverCode>, the range is curried into
3409+
either endpoint is a C<WhateverCode>, the range is primed into
34103410
another C<WhateverCode>.
34113411

34123412
For other types, ranges may be composed for any two arguments
@@ -3518,7 +3518,7 @@ If applied to a type name, it indicates the metaclass instance instead,
35183518
so C<^Moose> is short for C<HOW(Moose)> or C<Moose.HOW>. It still kinda
35193519
means "what is this thing's domain" in an abstract sort of way.
35203520

3521-
=head2 Auto-currying of ranges
3521+
=head2 Auto-priming of ranges
35223522

35233523
[This section is conjectural, and may be ignored for 6.0.]
35243524

@@ -4376,7 +4376,7 @@ you can write an explicit list operator:
43764376
}
43774377

43784378
or you can let the system autogenerate one for you based on the
4379-
corresponding infix operator, probably by currying:
4379+
corresponding infix operator, probably by priming:
43804380

43814381
&prefix:<[*]> ::= &reduce.assuming(&infix:<*>, 1);
43824382
&prefix:<[**]> ::= &reducerev.assuming(&infix:<**>);

S04-control.pod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ submethod gets the return value as the topic, just as exit phasers do.
15411541
Any phaser defined in the lexical scope of a method is a closure that
15421542
closes over C<self> as well as normal lexicals. (Or equivalently,
15431543
an implementation may simply turn all such phasers into submethods
1544-
whose curried invocant is the current object.)
1544+
whose primed invocant is the current object.)
15451545

15461546
=head1 Statement parsing
15471547

S06-routines.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,7 +2955,7 @@ that contains it.
29552955
[Note: to refer to any C<$?> or C<&?> variable at the time the sub or
29562956
block is being compiled, use the C<< COMPILING:: >> pseudopackage.]
29572957

2958-
=head2 Currying
2958+
=head2 Priming
29592959

29602960
Every C<Callable> object has a C<.assuming> method. This method does a partial
29612961
binding of a set of arguments to a signature and returns a new function
@@ -2987,7 +2987,7 @@ module's subroutines/methods/etc. simultaneously:
29872987

29882988
This special form should generally be restricted to named parameters.
29892989

2990-
To curry a particular C<multi> variant, it may be necessary to specify the type
2990+
To prime a particular C<multi> variant, it may be necessary to specify the type
29912991
for one or more of its parameters to pick out a single function:
29922992

29932993
&woof ::= &bark:(Dog).assuming :pitch<low>;

S12-objects.pod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ declared after it in the same scope, More specifically, it is the
10821082
generic prototype of a dispatcher, which must be instantiated anew
10831083
in each scope that has a different candidate list. (This works
10841084
much like type punning from roles to classes. Or you can think of
1085-
this dispatcher as a currying of the proto's code with the candidate
1085+
this dispatcher as a priming of the proto's code with the candidate
10861086
list appropriate to the scope.) For the sake of discussion, let us
10871087
say that there is a declarator equivalent to C<only> that is instead
10881088
spelled C<dispatch>. Generally a user never writes a C<dispatch> sub

S32-setting-library/Numeric.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ Returns the nearest integer to C<$x>. The algorithm is:
272272

273273
(Other rounding algorithms will be given extended names beginning with "round".)
274274

275-
Functions that round to a particular precision may easily be created with
276-
currying:
275+
Functions that round to a particular precision may easily be created by
276+
priming:
277277

278278
constant &roundcents ::= &round.assuming(:scale(1/100));
279279

0 commit comments

Comments
 (0)