Changeset 1375
- Timestamp:
- 12/13/09 07:48:13 (15 years ago)
- Files:
-
- trunk/docsrc/expression.dd (modified) (4 diffs)
- trunk/docsrc/pragma.dd (modified) (1 diff)
- trunk/docsrc/statement.dd (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docsrc/expression.dd
r1365 r1375 682 682 $(GLINK DeleteExpression) 683 683 $(GLINK CastExpression) 684 684 $(LINK2 class.html#anonymous, $(I NewAnonClassExpression)) 685 685 ) 686 686 687 687 688 688 <h3>New Expressions</h3> 689 689 690 690 $(GRAMMAR 691 691 $(GNAME NewExpression): 692 $(I NewArguments) $(I Type) $(B [) $( IAssignExpression) $(B ])692 $(I NewArguments) $(I Type) $(B [) $(GLINK AssignExpression) $(B ]) 693 693 $(I NewArguments) $(I Type) $(B $(LPAREN)) $(GLINK ArgumentList) $(B $(RPAREN)) 694 694 $(I NewArguments) $(I Type) 695 695 $(I NewArguments) $(I ClassArguments) $(I BaseClasslist)<sub>opt</sub> $(B {) $(I DeclDefs) $(B } ) 696 696 697 697 $(GNAME NewArguments): 698 698 $(B new $(LPAREN)) $(GLINK ArgumentList) $(B $(RPAREN)) 699 699 $(B new ( )) 700 700 $(B new) 701 701 702 702 $(GNAME ClassArguments): 703 703 $(B class $(LPAREN)) $(GLINK ArgumentList) $(B $(RPAREN)) 704 704 $(B class ( )) 705 705 $(B class) 706 706 707 707 $(GNAME ArgumentList): 708 $( IAssignExpression)709 $( IAssignExpression) $(B ,) $(I ArgumentList)708 $(GLINK AssignExpression) 709 $(GLINK AssignExpression) $(B ,) $(I ArgumentList) 710 710 ) 711 711 712 712 $(P $(I NewExpression)s are used to allocate memory on the garbage 713 713 collected heap (default) or using a class or struct specific allocator. 714 714 ) 715 715 716 716 $(P To allocate multidimensional arrays, the declaration reads 717 717 in the same order as the prefix array declaration order. 718 718 ) 719 719 … … 928 928 expression in the $(I ExpressionTuple), which is the result 929 929 of the $(I IndexExpression). 930 930 It is an error if $(I n) is out of bounds of the $(I ExpressionTuple). 931 931 ) 932 932 933 933 <h2>Slice Expressions</h2> 934 934 935 935 $(GRAMMAR 936 936 $(GNAME SliceExpression): 937 937 $(GLINK PostfixExpression) $(B [ ]) 938 $(GLINK PostfixExpression) $(B [) $( I AssignExpression) $(B ..) $(IAssignExpression) $(B ])938 $(GLINK PostfixExpression) $(B [) $(GLINK AssignExpression) $(B ..) $(GLINK AssignExpression) $(B ]) 939 939 ) 940 940 941 941 $(P $(I PostfixExpression) is evaluated. 942 942 if $(I PostfixExpression) is an expression of type 943 943 static array or dynamic array, the variable $(B length) 944 944 (and the special variable $(DOLLAR)) 945 945 is declared and set to be the length of the array. 946 946 A new declaration scope is created for the evaluation of the 947 $( I AssignExpression)..$(IAssignExpression)947 $(GLINK AssignExpression)..$(GLINK AssignExpression) 948 948 and $(B length) (and $(DOLLAR)) appears in that scope only. 949 949 ) 950 950 951 951 $(P The first $(I AssignExpression) is taken to be the inclusive 952 952 lower bound 953 953 of the slice, and the second $(I AssignExpression) is the 954 954 exclusive upper bound. 955 955 The result of the expression is a slice of the $(I PostfixExpression) 956 956 array. 957 957 ) … … 1122 1122 string literal. 1123 1123 ) 1124 1124 1125 1125 <h3>Array Literals</h3> 1126 1126 1127 1127 $(GRAMMAR 1128 1128 $(GNAME ArrayLiteral): 1129 1129 $(B [) $(GLINK ArgumentList) $(B ]) 1130 1130 ) 1131 1131 1132 $(P Array literals are a comma-separated list of $( IAssignExpression)s1132 $(P Array literals are a comma-separated list of $(GLINK AssignExpression)s 1133 1133 between square brackets [ and ]. 1134 1134 The $(I AssignExpression)s form the elements of a static array, 1135 1135 the length of the array is the number of elements. 1136 1136 The type of the first element is taken to be the type of 1137 1137 all the elements, and all elements are implicitly converted 1138 1138 to that type. 1139 1139 If that type is a static array, it is converted to a dynamic 1140 1140 array. 1141 1141 ) 1142 1142 … … 1346 1346 or non-nested functions, and the $(B delegate) form is 1347 1347 analogous to non-static nested functions. In other words, 1348 1348 a delegate literal can access stack variables in its enclosing 1349 1349 function, a function literal cannot. 1350 1350 1351 1351 1352 1352 <h3>Assert Expressions</h3> 1353 1353 1354 1354 $(GRAMMAR 1355 1355 $(GNAME AssertExpression): 1356 $(B assert $(LPAREN)) $( IAssignExpression) $(B $(RPAREN))1357 $(B assert $(LPAREN)) $( I AssignExpression) $(B ,) $(IAssignExpression) $(B $(RPAREN))1356 $(B assert $(LPAREN)) $(GLINK AssignExpression) $(B $(RPAREN)) 1357 $(B assert $(LPAREN)) $(GLINK AssignExpression) $(B ,) $(GLINK AssignExpression) $(B $(RPAREN)) 1358 1358 ) 1359 1359 1360 1360 $(P Asserts evaluate the $(I expression). If the result is false, 1361 1361 an $(B AssertError) is thrown. If the result is true, then no 1362 1362 exception is thrown. 1363 1363 It is an error if the $(I expression) contains any side effects 1364 1364 that the program depends on. The compiler may optionally not 1365 1365 evaluate assert expressions at all. 1366 1366 The result type of an assert expression is $(TT void). 1367 1367 Asserts are a fundamental part of the trunk/docsrc/pragma.dd
r671 r1375 1 1 Ddoc 2 2 3 3 $(SPEC_S Pragmas, 4 4 5 5 $(GRAMMAR 6 6 $(GNAME Pragma): 7 7 $(B pragma) $(B $(LPAREN)) $(I Identifier) $(B $(RPAREN)) 8 $(B pragma) $(B $(LPAREN)) $(I Identifier) $(B ,) $(I ExpressionList) $(B $(RPAREN)) 9 10 $(GNAME ExpressionList): 11 $(I ExpressionList) $(B ,) $(I Expression) 12 $(I Expression) 8 $(B pragma) $(B $(LPAREN)) $(I Identifier) $(B ,) $(LINK2 expression.html#ArgumentList, $(I ArgumentList)) $(B $(RPAREN)) 13 9 ) 14 10 15 11 16 12 $(P Pragmas are a way to pass special information to the compiler 17 13 and to add vendor specific extensions to D. 18 14 Pragmas can be used by themselves terminated with a ';', 19 15 they can influence a statement, a block of statements, a declaration, or 20 16 a block of declarations. 21 17 ) 22 18 trunk/docsrc/statement.dd
r1346 r1375 799 799 800 800 A switch statement goes to one of a collection of case 801 801 statements depending on the value of the switch 802 802 expression. 803 803 804 804 $(GRAMMAR 805 805 $(I SwitchStatement): 806 806 $(B switch $(LPAREN)) $(EXPRESSION) $(B $(RPAREN)) $(PSSCOPE) 807 807 808 808 $(GNAME CaseStatement): 809 $(B case) $( I ExpressionList) $(B :) $(PSSEMI_PSCURLYSCOPE)809 $(B case) $(LINK2 expression.html#ArgumentList, $(I ArgumentList)) $(B :) $(PSSEMI_PSCURLYSCOPE) 810 810 811 811 $(V2 $(GNAME CaseRangeStatement): 812 812 $(B case) $(I FirstExp) $(B : .. case) $(I LastExp) $(B :) $(PSSEMI_PSCURLYSCOPE) 813 813 814 814 $(I FirstExp): 815 815 $(I AssignExpression) 816 816 817 817 $(I LastExp): 818 818 $(I AssignExpression) 819 819 ) … … 821 821 $(B default :) $(PSSEMI_PSCURLYSCOPE) 822 822 ) 823 823 824 824 $(P $(EXPRESSION) is evaluated. The result type T must be 825 825 of integral type or $(CODE char[]), $(CODE wchar[]) or $(CODE dchar[]). 826 826 The result is 827 827 compared against each of the case expressions. If there is 828 828 a match, the corresponding case statement is transferred to. 829 829 ) 830 830 831 $(P The case expressions, $( I ExpressionList), are a comma separated832 list of expressions.831 $(P The case expressions, $(LINK2 expression.html#ArgumentList, $(I ArgumentList)), 832 are a comma separated list of expressions. 833 833 ) 834 834 835 835 $(V2 836 836 $(P A $(I CaseRangeStatement) is a shorthand for listing a series 837 837 of case statements from $(I FirstExp) to $(I LastExp). 838 838 ) 839 839 ) 840 840 841 841 $(P If none of the case expressions match, and there is a default 842 842 statement, the default statement is transferred to.
