Skip to content

Commit 1ce53ae

Browse files
committed
more FAQ clarifications
1 parent 4eed22e commit 1ce53ae

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

doc/Language/faq.pod

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,13 @@ There are several reasons:
287287
288288
=item they make it easy to interpolate variables into strings
289289
290-
=item they form micro-namespaces for different variables, thus avoiding name clashes
290+
=item they form micro-namespaces for different variables and twigils, thus avoiding name clashes
291291
292292
=item they allow easy single/plural distinction
293293
294-
=item many natural languages use mandatory noun markers, so our brains are built to handle it
294+
=item they work like natural languages that use mandatory noun markers, so our brains are built to handle it
295+
296+
=item they aren't mandatory, since you can declare sigilless names (if you don't mind the ambiguity)
295297
296298
297299
=head2 Does Perl 6 have coroutines? What about C<yield>?
@@ -309,7 +311,7 @@ routines that return lazy lists:
309311
310312
# second method, use .map or similar method
311313
# on a lazy list
312-
my @squares = (1..*).map(-> $x { $x * $x });
314+
my @squares = (1..*).map(-> \x { });
313315
314316
=head2 Why can't I initialize private attributes from the new method, and how can I fix this?
315317
@@ -345,6 +347,10 @@ for more details) with all the named arguments that the user passes to the
345347
constructor. C<:$!x> is a named parameter with name C<x>, and when called
346348
with a named argument of name C<x>, its value is bound to the attribute C<$!x>.
347349
350+
But don't do that. If the name is public, there is no downside to
351+
declaring it that way with C<$.x> since the external view is readonly
352+
by default, and you can still access it internally with C<$!x>.
353+
348354
=head2 How and why do C<say> and C<print> differ?
349355
350356
The most obvious difference is that C<say> appends a newline at the
@@ -370,6 +376,7 @@ nothing in that value except the type).
370376
371377
So C<say> is optimized for debugging and display to people, C<print>
372378
is more suitable for producing output for other programs to consume.
379+
(Use C<put> if you want C<print> semantics with a newline.)
373380
374381
=head2 What's the difference between C<token> and C<rule> ?
375382
@@ -392,15 +399,15 @@ C<regex> declares a plain regex without any implied modifiers.
392399
393400
C<die> throws an exception.
394401
395-
If C<use fatal;> (which is dynamically scoped) is in scope, C<fail> also
396-
throws an exception. Otherwise it returns a C<Failure> from the routine
397-
it is called from.
402+
C<fail> returns a C<Failure> object. (If the caller has declared C<use fatal;>
403+
in the calling lexical scope, C<fail> instead throws an exception
404+
instead of returning.)
398405
399-
A C<Failure> is an "unthrown" or "soft" exception. It is an object that
400-
contains the exception, and throws the exception when the Failure is used
401-
as an ordinary object.
406+
A C<Failure> is an "unthrown" or "lazy" exception. It is an object that
407+
contains the exception, and throws the exception if you try to use the C<Failure>
408+
as an ordinary object, or ignore it in sink context.
402409
403-
A Failure returns False from a C<defined> check, and you can extract
410+
A C<Failure> returns C<False> from a C<defined> check, and you can extract
404411
the exception with the C<exception> method.
405412
406413
=head2 Why is C<wantarray> or C<want> gone? Can I return different things in different contexts?

0 commit comments

Comments
 (0)