@@ -984,7 +984,7 @@ and never as
984
984
The C<*> character as a standalone term captures the notion of "Whatever",
985
985
the meaning of which can be decided lazily by whatever it is an argument to.
986
986
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
988
988
that takes one or two arguments. (See below.)
989
989
990
990
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>.
1016
1016
[Conjecture: actually, this is negotiable--we might shorten it
1017
1017
to C<is like(Whatever)> or some such. C<:-)>]
1018
1018
1019
- =head3 Currying of Unary and Binary Operators
1019
+ =head3 Priming of Unary and Binary Operators with Whatever
1020
1020
1021
1021
For any unary or binary operator (specifically, any prefix, postfix,
1022
1022
and infix operator), if the operator has not specifically requested
1023
1023
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
1025
1026
built-in numeric operators fall into this category, so:
1026
1027
1027
1028
* - 1
1028
1029
'.' x *
1029
1030
* + *
1030
1031
1031
- are internally curried into closures of one or two arguments:
1032
+ are internally primed into closures of one or two arguments:
1032
1033
1033
1034
{ $^x - 1 }
1034
1035
{ '.' x $^y }
@@ -1040,30 +1041,30 @@ with the result that
1040
1041
1041
1042
* + (state $s = 0)
1042
1043
1043
- is effectively curried into:
1044
+ is effectively primed into:
1044
1045
1045
1046
-> $x { $x + (state $OUTER::s = 0) }
1046
1047
1047
1048
rather than:
1048
1049
1049
1050
-> $x { $x + (state $s = 0) }
1050
1051
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.
1052
1053
(Though it does have a dynamic scope when it runs.) This prevents the
1053
1054
semantics from changing drastically if the operator in question
1054
1055
suddenly decides to handle C<Whatever> itself.
1055
1056
1056
1057
As a postfix operator, a method call is one of those operators that is
1057
- automatically curried . Something like:
1058
+ automatically primed . Something like:
1058
1059
1059
1060
*.meth(1,2,3)
1060
1061
1061
1062
is rewritten as:
1062
1063
1063
1064
{ $^x.meth(1,2,3) }
1064
1065
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:
1067
1068
1068
1069
@primes = grep *.prime, 2..*;
1069
1070
subset Duck where *.^can('quack');
@@ -1081,9 +1082,9 @@ or its derivative closures can distinguish them by type:
1081
1082
0, 1, *+1 ... * # counting
1082
1083
0, 1, *+* ... * # fibonacci
1083
1084
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
1087
1088
far as it makes sense, including outward through metaoperators. Hence:
1088
1089
1089
1090
* + 2 + 3 # { $^x + 2 + 3 }
@@ -1097,12 +1098,12 @@ far as it makes sense, including outward through metaoperators. Hence:
1097
1098
This is only for operators that are not C<Whatever>-aware. There is no requirement
1098
1099
that a C<Whatever>-aware operator return a C<WhateverCode> when C<Whatever>
1099
1100
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
1101
1102
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
1103
1104
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:
1106
1107
1107
1108
"foo" xx * # infinite supply of "foo"
1108
1109
"foo" xx *-1 # { "foo" xx $^a - 1 }
@@ -1125,13 +1126,13 @@ Operators that are known to return non-closure values with C<*> include:
1125
1126
$a = * # just assigns Whatever
1126
1127
$a ~~ * # just matches Whatever
1127
1128
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
1129
1130
assignment and smartmatching are not really normal binary operators, but
1130
1131
syntactic sugar for underlying primitives. (Such pseudo operators
1131
1132
may also place restrictions on which meta-operators work on them.)
1132
1133
1133
1134
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
1135
1136
WhateverCode closures as the stopper:
1136
1137
1137
1138
0 ...^ *>5 # means 0, 1, 2, 3, 4, 5
0 commit comments