Skip to content

Commit 234352b

Browse files
committed
Type/Signature: changed confusing variable name
The variable `$closure` seems a bit prone to creating confusion here; while the variable itself _is_ participating in a closure, closing over the returned anonymous sub, we usually use "a closure" in the nounal form to refer to a function enclosing something or ocassionally to refer to a variable whose use is integral and obvious to the purpose of the entire closure (as, say an iteration cursor). In this case, it's simply a `C` value (where `C` is a type that can participate as both arguments to `infix:</>`) that the closure sub is remembering for later. So let's change its name to `$division`, since that's more functional to the purpose. (I'd be fine with an extremely formal name like `$C-result`, too, but the current `$closure` seems neither fish nor fowl.) --- p.s. Technically, we might be using a type where the result of an `infix:</>` operation may not be correctly be referred to as "a division", but it seems clearer than "closure" nonetheless. The existence of an `(Any, Any --> Numeric:D)` multi seems to make this a safe assumption, if not a guarantee. If it _were_ guaranteed to always represent division, C<$quotient> would be better, perhaps, but C<$division> seems to offer a reasonable compromise to get the point across.
1 parent 30b1bfd commit 234352b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doc/Type/Signature.pod6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,9 +724,9 @@ the function body.
724724
sub f(::T $p1, T $p2, ::C){
725725
# $p1 and $p2 are of the same type T, that we don't know yet
726726
# C will hold a type we derive from a type object or value
727-
my C $closure = $p1 / $p2;
727+
my C $division = $p1 / $p2;
728728
return sub (T $p1) {
729-
$closure * $p1;
729+
$division * $p1;
730730
}
731731
}
732732

0 commit comments

Comments
 (0)