Skip to content
This repository
Browse code

spec postcircumfix behavior under Whatever

  • Loading branch information...
commit 26c204cfad070e097d16b8e496113add500c24c3 1 parent 8ece611
Larry Wall TimToady authored

Showing 1 changed file with 30 additions and 3 deletions. Show diff stats Hide diff stats

  1. +30 3 S02-bits.pod
33 S02-bits.pod
Source Rendered
@@ -13,8 +13,8 @@ Synopsis 2: Bits and Pieces
13 13
14 14 Created: 10 Aug 2004
15 15
16   - Last Modified: 20 Aug 2013
17   - Version: 276
  16 + Last Modified: 26 Sep 2013
  17 + Version: 277
18 18
19 19 This document summarizes Apocalypse 2, which covers small-scale
20 20 lexical items and typological issues. (These Synopses also contain
@@ -1128,6 +1128,13 @@ does not make a list of closures, but is equivalent to
1128 1128
1129 1129 -> $arg { @array X* $arg }
1130 1130
  1131 +Postcircumfixes (with or without the dot) are also autoprimed, so we have
  1132 +
  1133 + *[$x] -> @a { @a[$x] }
  1134 + *{$x} -> %h { %h[$x] }
  1135 + *<foo> -> %h { %h<foo> }
  1136 + *($x) -> &c { &c($x) }
  1137 +
1131 1138 =head3 The C<WhateverCode> Types
1132 1139
1133 1140 These returned closures are of type C<WhateverCode:($)> or C<WhateverCode:($,$)>
@@ -1140,7 +1147,7 @@ or its derivative closures can distinguish them by type:
1140 1147 0, 1, *+1 ... * # counting
1141 1148 0, 1, *+* ... * # fibonacci
1142 1149
1143   -For any prefix, postfix, or infix operator that would be primed by a
  1150 +For any prefix, infix, postfix, or postcircumfix operator that would be primed by a
1144 1151 C<Whatever>, a C<WhateverCode> also autoprimes it, such that any noun
1145 1152 phrase based on C<*> as a head noun autoprimes transitively outward as
1146 1153 far as it makes sense, including outward through metaoperators. Hence:
@@ -1151,6 +1158,26 @@ far as it makes sense, including outward through metaoperators. Hence:
1151 1158 (-*.abs)i # { (-$^x.abs)i }
1152 1159 @a «+» * # { @a «+» $^x }
1153 1160
  1161 +Note in particular that parentheses will autoprime on a C<WhateverCode>, so
  1162 +
  1163 + *[0](1,2,3,4,5)
  1164 +
  1165 +means
  1166 +
  1167 + -> @a { @a[0](1,2,3,4,5) }
  1168 +
  1169 +rather than
  1170 +
  1171 + (-> @a { @a.[0] })(1,2,3,4,5)
  1172 +
  1173 +If you want the latter semantics for some reason, use a temporary:
  1174 +
  1175 + my $c = *[0]; $c(1,2,3,4,5);
  1176 +
  1177 +or just put the autoprime in parens:
  1178 +
  1179 + (*[0])(1,2,3,4,5)
  1180 +
1154 1181 =head3 Operators with idiosyncratic Whatever
1155 1182
1156 1183 The above is only for operators that are not C<Whatever>-aware. There is no requirement

0 comments on commit 26c204c

Please sign in to comment.
Something went wrong with that request. Please try again.