A couple weeks ago I alluded that I was working on some documentation.
After a brief hiatus, I've picked it back up, and am ready to release....
an entire half document. Big whoopee.
Anyway, what I'm working on is more or less a Statement of Fact, from a Perl
6 language perspective. It is intended to be a seed for an actual language
spec to be produced and maintained... someday.
Larry's Apocalypses give an overview on what is changing for Perl 6.
Damian's Exegeses show the Apocalypse in motion. [1] This is the third
step - to give a more comprehensive view of exactly how Perl 6 will look and
feel.
Using information gathered from the A&E series, the Camel III, Vroman's
Pocket Guide, the mailing lists, pointed questions, existing Perl (5.6.1)
behavior, and, when all else fails, my own judgement, I'm attempting to
document in excruciatingly mundane detail [2] a complete picture of Perl 6 -
the language, and how it interacts with the internals - and an accurate
target for the Perl 6 language, so that coders know exactly what they are
coding, and testers know exactly what to test.
A secondary goal is to help assist Larry and company in the language design.
A lot of information was presented, and there are some very good ideas. But
it is a very big picture, and perhaps a complete, distilled view may show
some areas that may need review, rethinking, or removal.
I've got two currently in the works. The first is on "Statements and
Blocks", which is included below. The second is on operators.
I'm not particular happy with the format, but I haven't found a decent one
yet. One of the first things I wish to add are references to the actual
source of the information I base each decision on. (Apo 2, p5p, 5.6.1, etc.)
Lastly, it's a living document. The language is in flux, and this document
will attempt to shadow as closely as possible.
Suggestions, corrections, and, of course, additions, are more than welcome.
As is, of course, friendly debate... :-)
[1] Apologies to Dave Barry, but wouldn't "Apocalypse in Motion" be a good
name for a band? Perhaps at the next Perl Jam....
[2] ie, no humorous footnotes. [3]
[3] Not even this one.
--------------------------
Perl 6 Reference - Statements and Blocks
(0.1/2001-09-01)
Syntax Overview
Keywords
continue, do, else, elsif, for, foreach, given, goto, grep, if, last,
map, next, redo, sort, sub, unless, until, when, while
Basic Constructs
1. [ LABEL: ] expr;
2. [ LABEL: ] { block } [ continue { block } ]
3. << grep | map >> { block } list # Note 1
4. sort [ { block } ] list # Note 1
5. do { block } # Note 1
Conditional Statement Modifiers
6. [ LABEL: ] expr if expr;
7. [ LABEL: ] expr until expr;
Looping Statement Modifiers
8. [ LABEL: ] expr while expr;
9. [ LABEL: ] do { block } while expr; # Note 2
10. [ LABEL: ] expr until expr;
11. [ LABEL: ] do { block } until expr; # Note 3
Iterative Statement Modifiers
12. [ LABEL: ] expr for[each] list; # Note 4
Conditional Block Constructs
13. [ LABEL: ] if ( expr ) { block }
[ [ elsif ( expr ) { block } ] ... ]
[ else { block } ]
14. [ LABEL: ] until ( expr ) { block }
[ [ elsif ( expr ) { block } ] ... ]
[ else { block } ]
15. [ LABEL: ] given ( expr ) { block }
16. [ LABEL: ] when expr : { block } # Note 5
Looping Block Constructs
17. [ LABEL: ] while ( expr ) { block } [ continue { block } ]
18. [ LABEL: ] until ( expr ) { block } [ continue { block } ]
19. [ LABEL: ] for[each] ( expr; expr; expr ) # Note 4
{ block }
Iterative Block Constructs
20. [ LABEL: ] for[each] [ scalar ] ( list ) { block } # Note 4
Subroutine Code Blocks # Note 6
21. sub identifier [ ( prototype ) ] [ :properties ] { block }
22. sub [ ( prototype ) ] { block } # Note 7
Definitions
An expression (expr) consists of one or more terms, operators, and
expressions.
A list consists of zero or more expressions. List members may either be
an explicit expression, separated via a comma (','), or may be interpolated
from two expressions via either of the two range operators
( ('..') and ('...') ). A list of zero elements must be delimited by
parenthesis.
A statement consists of zero or more expressions, followed by an optional
modifier and its expression, and either a statement terminator (';') or a
block closure ('}' or EOF).
A block consists of zero or more blocks and statements. A file is
considered a block, delimited by the file boundaries. Semantically, I
will define a block only in terms of its affect on scoping. (Blocks are
sometimes referenced by their interaction with flow control. However, this
definition isn't consistent, and I will avoid it.)
Flow Control Expressions
A. goto
B.
last
next
redo
Detailed Descriptions
(Here, I'll go into exactly how each one of these is different from
all the others, and explain each construct's interaction with flow control
expressions and internals....)
Notes
1. An expression which uses a block.
2. A specialized form of 5.
3. A specialized form of 7.
4. 'for' and 'foreach' are synonymous.
5. 'when' is only a valid construct when directly within a 'given'
construct.
6. Subroutines are covered in depth in a separate document.
7. An anonymous subroutine is technically an expression.
--
Bryan C. Warnock
[EMAIL PROTECTED]