Skip to content

Commit 8fb69e4

Browse files
committed
Moved test to right place closes #1934
1 parent aceae82 commit 8fb69e4

File tree

2 files changed

+1
-35
lines changed

2 files changed

+1
-35
lines changed

doc/Language/5to6-perlfunc.pod6

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,9 +2080,7 @@ As with C<wait>, the disposition of this is unclear.
20802080
20812081
=item wantarray
20822082
2083-
There is no C<wantarray> in Perl 6, because L<reasons|/language/faq#Why_is_wantarray_or_want_gone?_Can_I_return_different_things_in_different_contexts?>.
2084-
2085-
There are very easy ways to cover many of the use cases which wantarray filled.
2083+
There is no C<wantarray> in Perl 6; however, there are very easy ways to cover many of the use cases which wantarray filled.
20862084
20872085
First, since Perl 6 does not need special reference syntax to contain
20882086
a C<List> or C<Array> in a C<Scalar>, simply returning a list may be

doc/Language/faq.pod6

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -623,38 +623,6 @@ as an ordinary object, or ignore it in sink context.
623623
A C<Failure> returns C<False> from a C<defined> check, and you can extract
624624
the exception with the C<exception> method.
625625
626-
=head2 Why is C<wantarray> or C<want> gone?
627-
Can I return different things in different contexts?
628-
629-
Perl 5 has the L<C<wantarray>|/language/5to6-perlfunc#wantarray> function that
630-
tells you whether it's called in void, scalar or list context. Perl 6 has no
631-
equivalent construct because context does not flow inwards; i.e.,
632-
a routine would need time travel to know which context it's called in because
633-
context is lazy (known only when the results are used later).
634-
635-
For example, Perl 6 has multiple dispatch. So, in a code example like
636-
637-
=begin code :preamble<sub f {}>
638-
multi w(Int $x) { say 'Int' }
639-
multi w(Str $x) { say 'Str' }
640-
w(f());
641-
=end code
642-
643-
there's no way to determine if the caller of sub C<f> wants a string or
644-
an integer, because it's not yet known what the caller is. In general
645-
this requires solving the halting problem, which even Perl 6 compiler
646-
writers have trouble with.
647-
648-
One way to achieve context sensitivity in Perl 6 is to return an object
649-
that knows how to respond to method calls that are typical for a context.
650-
In Perl 6, this is actually a L<lot easier|/language/5to6-perlfunc#wantarray>
651-
than it may sound, and other features of the language either mitigate the
652-
need to do so in the first place or make it possible to cover most of the
653-
use cases of wantarray.
654-
655-
For example, regex matches return L<Match objects that know how to respond
656-
to list indexing, hash indexing, and that can turn into the matched
657-
string|/type/Match>.
658626
659627
=head2 What's the difference between C<Pointer> and C<OpaquePointer>?
660628

0 commit comments

Comments
 (0)