@@ -16,7 +16,7 @@ $(HEADERNAV_TOC)
16
16
internals, but don't get confused - they don't have much in common with tuples that
17
17
commonly exist in other languages. Sequences of values of different types that can be
18
18
returned from functions are provided by $(PHOBOS typecons, .Tuple, std.typecons.Tuple).
19
- Using term "tuple" to mean compile-time sequences is discouraged to avoid confusion, and if encountered
19
+ Using the term "tuple" to mean compile-time sequences is discouraged to avoid confusion, and if encountered
20
20
should result in a $(LINK2 https://issues.dlang.org, documentation bug report).
21
21
)
22
22
@@ -115,7 +115,7 @@ $(H2 $(LNAME2 available-operations, Available operations))
115
115
116
116
$(P D's $(LINK2 spec/statement.html#ForeachStatement, foreach statement) has special
117
117
semantics when iterating over compile-time sequences. It repeats the body of the loop
118
- for each of the sequence elements, with the loop iteration "variable" becoming an alias
118
+ for each of the sequence elements, with the loop iteration symbol being an alias
119
119
for each compile-time sequence element in turn.
120
120
)
121
121
@@ -134,7 +134,6 @@ $(H2 $(LNAME2 available-operations, Available operations))
134
134
}
135
135
136
136
/* Prints:
137
-
138
137
int
139
138
string
140
139
void()
@@ -172,7 +171,7 @@ $(H2 $(LNAME2 homogenous-sequences, Homogenous sequences))
172
171
173
172
$(P An $(ALOCAL AliasSeq, AliasSeq) that consists of only type or value elements are
174
173
commonly called "type sequences" or "value sequences" respectively. The concept of
175
- a "symbol sequence" is rarely mentioned explicitly but fits the same pattern.
174
+ a "symbol sequence" is used less frequently but fits the same pattern.
176
175
)
177
176
178
177
$(H3 $(LNAME2 type-seq, Type sequences))
@@ -208,8 +207,8 @@ $(H4 $(LNAME2 type-seq-instantiation, Type sequence instantiation))
208
207
alias variables = AliasSeq!(__var1, __var2, __var3);
209
208
---
210
209
211
- $(P So a type sequence instance acts as a symbol sequence that only aliases
212
- variables.)
210
+ $(P So a type sequence instance is a kind of symbol sequence that only aliases
211
+ variables, known as an $(I lvalue sequence) .)
213
212
214
213
$(P $(DDSUBLINK spec/template, variadic-templates, Variadic template functions)
215
214
use a type sequence instance for a function parameter:)
@@ -229,20 +228,39 @@ $(H4 $(LNAME2 type-seq-instantiation, Type sequence instantiation))
229
228
230
229
$(H3 $(LNAME2 value-seq, Value sequences))
231
230
232
- $(P It is possible to use value sequences with values of the same type to declare array literals :)
231
+ $(P It is possible to use a sequence of values of the same type to declare an array literal :)
233
232
234
233
---
235
234
import std.meta;
236
- static assert ([ AliasSeq!(1, 2, 3) ] == [ 1, 2, 3 ]);
235
+ enum e = 3;
236
+ enum arr = [ AliasSeq!(1, 2, e) ];
237
+ static assert(arr == [ 1, 2, 3 ]);
237
238
---
238
239
239
- $(H3 $(LNAME2 symbol-seq, Symbol sequences))
240
+ $(P The above sequence is an $(I rvalue sequence), as it is comprised only of literal values
241
+ and manifest constants. Each element's value is known at compile-time.)
242
+
243
+ $(P The following demonstrates use of an $(I lvalue sequence):)
244
+ ---
245
+ import std.meta, std.algorithm;
246
+ auto x = 3, y = 7;
247
+ alias pair = AliasSeq!(x, y);
248
+ swap(pair);
249
+ assert(x == 7 && y == 3);
250
+ ---
251
+ $(P As above, such sequences may use $(ALOCAL assignment, assignment).)
252
+
253
+ $(H4 $(LNAME2 tupleof, Aggregate field sequences))
240
254
241
255
$(P $(DDSUBLINK spec/class, class_properties, `.tupleof`) is a
242
- class/struct instance property that provides a symbol sequence
243
- of fields.)
256
+ class/struct instance property that provides an lvalue sequence
257
+ of each field.)
258
+
259
+ $(H3 $(LNAME2 symbol-seq, Symbol sequences))
244
260
245
- )
261
+ $(P A symbol sequence aliases any named symbol - types, variables, functions and templates -
262
+ but not literals.
263
+ Like an alias sequence, the kind of elements can be mixed.)
246
264
247
265
Macros:
248
266
TITLE=Compile-time Sequences
0 commit comments