Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Syntax: Statements and expressions
  • Loading branch information
moritz committed Apr 4, 2015
1 parent ae713fe commit 8f9b970
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions lib/Language/syntax.pod
Expand Up @@ -128,18 +128,38 @@ of comment
say 'code again';
=end code
=head1 Statements and Expressions
Perl 6 programs are made of lists of statements. A special case of a statement
is an I<expression>, which returns a value. For example C<if True { say 42 }>
is syntactically a statement, but not an expression, whereas C<1 + 2> is an
expression (and thus also a statement).
The C<do> prefix turns statements into expressions. So while
my $x = if True { 42 }; # Syntax error!
is an error,
my $x = do if True { 42; };
assign the return value of the if statement (here C<42>) to the variable
C<$x>.
=begin comment
=head1 Statements and Expressions
=head1 Terms
TODO
=head1 Terms
=head3 Variables
TODO
=head2 Literals
TODO
=head3 String literals
TODO: link to quotes
Expand All @@ -164,6 +184,10 @@ TODO
TODO
=head2 Subroutine calls
TODO
=head1 Operators
TODO: link to language/operators
Expand Down

0 comments on commit 8f9b970

Please sign in to comment.