Skip to content

Commit

Permalink
Expand hyper methcall info
Browse files Browse the repository at this point in the history
Document the whole nodality business.
(really wordy paragraph; could use improvement)
  • Loading branch information
zoffixznet committed Sep 7, 2018
1 parent 3249f65 commit 3663c35
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/Language/operators.pod6
Expand Up @@ -708,6 +708,16 @@ X<Hyper method call operator>. Will call a method on all elements of a C<List> o
say @a».&foo; # So we can pretend to have a method call with a sub that got a good first positional argument.
say @a».&{ .ord}; # Blocks have an implicit positional arguments that lands in $_. The latter can be omitted for method calls.
Hyper method calls may appear to be the same as doing a L<map> call, however along with being a hint to the compiler
that it can parallelize the call, the behaviour is also affected by L<nodality of the method|https://docs.perl6.org/routine/is%20nodal>
being invoked, depending on which either L<nodemap> or L<deepmap> semantics are used to perform the call.
The nodality is checked by looking up whether the L<Callable> provides C<nodal> method.
If the hyper is applied to a method, that L<Callable> is that method name, looked up on L<List> type;
if the hyper is applied to a routine (e.g. C<».&foo>), that routine functions as that L<Callable>. If the
L<Callable> is determined to provide C<nodal> method, L<nodemap> semantics are used to perform the hyper call,
otherwise L<duckmap> semantics are used.
Take care to avoid a
L<common mistake|/language/traps#Using_»_and_map_interchangeably> of expecting
side-effects to occur in order. The following C<say> is B<not>
Expand Down

0 comments on commit 3663c35

Please sign in to comment.