Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

[svn:perl6-synopsis] r14536 - doc/trunk/design/syn
Author: audreyt
Date: Wed Apr  2 10:22:01 2008
New Revision: 14536

Modified:
doc/trunk/design/syn/S04.pod

Log:
* S04: Create a new section, "Statement-level bare blocks"
since its content doesn't really belong in the "do-once loop"
section.

* S04: Also, clarify that statement-level blocks with placeholder
variables should trigger an error, unless prefixed with "do"
or postfixed with a modifier.


Modified: doc/trunk/design/syn/S04.pod
 ========================================
====================================
==
--- doc/trunk/design/syn/S04.pod	(original)
+++ doc/trunk/design/syn/S04.pod	Wed Apr  2 10:22:01 2008
@@ -12,9 +12,9 @@

Maintainer: Larry Wall <larry@wall.org>
Date: 19 Aug 2004
-  Last Modified: 8 Feb 2008
+  Last Modified: 2 Apr 2008
Number: 4
-  Version: 64
+  Version: 65

This document summarizes Apocalypse 4, which covers the block and
statement syntax of Perl.
@@ -533,15 +533,6 @@
useful for the do-once block, since it is offically a loop and can take
therefore loop control statements.

-Although a bare block is no longer a do-once loop, it still executes
-immediately as in PerlĀ_5, as if it were immediately dereferenced with
-a C<.()> postfix, so within such a block C<CALLER::> refers to the
-scope surrounding the block.  If you wish to return a closure from a
-function, you must use an explicit prefix such as C<return> or C<sub>
-or C<< -> >>.  (Use of a placeholder parameter is deemed insufficiently
-explicit because it's not out front where it can be seen.  You can, of
-course, use a placeholder parameter if you also use C<return>.)
-
Another consequence of this is that any block just inside a
left parenthesis is immediately called like a bare block, so a
multidimensional list comprehension may be written using a block with
@@ -553,6 +544,32 @@

@names = ({ "$^name.$^num" } for 'a'..'zzz' X 1..100);

+=head2 Statement-level bare blocks
+
+Although a bare block occuring as a single statement is no longer
+a do-once loop, it still executes immediately as in PerlĀ_5, as if it
+were immediately dereferenced with a C<.()> postfix, so within such a
+block C<CALLER::> refers to the scope surrounding the block.
+
+If you wish to return a closure from a function, you must use an
+explicit prefix such as C<return> or C<sub> or C<< -> >>.
+
+Use of a placeholder parameter in statement-level blocks triggers a
+syntax error, because the parameter is not out front where it can be
+seen.  However, it's not an error when prefixed by a C<do>, or when
+followed by a statement modifier:
+
+    # Syntax error: Statement-level placeholder block
+    { say $^x };
+
+    # Not an syntax error, though $x doesn't get the argument it wants
+    do { say $^x };
+
+    # Not an error: Equivalent to "for 1..10 -> $x { say $x }"
+    { say $^x } for 1..10;
+
+    # Not an error: Equivalent to "if foo() -> $x { say $x }"
+    { say $^x } if foo();

=head2 The gather statement


Report this thread to moderator Post Follow-up to this message
Old Post
audreyt@cvs.perl.org
04-03-08 12:14 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL 6 Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 12:47 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.