You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$(P Interpolation Expression Sequences (IES) are expressions that intersperse string literal data, and values. An interpolation expression is written like a string, but can contain values that are passed directly to a function that is able to accept them. It is transformed into a $(I Sequence) of expressions that can be overloaded or handled by template functions.)
7
+
$(P Interpolation Expression Sequences (IES) are expressions that intersperse
8
+
string literal data, and values. An interpolation expression is written like a
9
+
string, but can contain values that are passed directly to a function that is
10
+
able to accept them. It is transformed into a $(I Sequence) of expressions that
11
+
can be overloaded or handled by template functions.)
$(P When the lexer encounters an Interpolation Expression Sequence, the token is translated into a sequence of expressions, which replaces the single token. The sequence always starts with the expression $(D core.interpolation.InterpolationHeader()) and always ends with $(D core.interpolation.InterpolationFooter()))
58
+
$(P When the lexer encounters an Interpolation Expression Sequence, the token
59
+
is translated into a sequence of expressions, which replaces the single token.
60
+
The sequence always starts with the expression
61
+
$(D core.interpolation.InterpolationHeader()) and always ends with
62
+
$(D core.interpolation.InterpolationFooter()))
55
63
56
-
$(P Each part $(D str) of the token which is literal string data is translated into the expression $(D core.interpolation.InterpolatedLiteral!(str)))
64
+
$(P Each part $(D str) of the token which is literal string data is translated
65
+
into the expression $(D core.interpolation.InterpolatedLiteral!(str)))
57
66
58
-
$(P Each part $(D $$(LPAREN)expr$(RPAREN)) of the token which is an $(GLINK InterpolationExpression) is translated into the sequence $(D core.interpolation.InterpolatedExpression!(expr), expr).)
67
+
$(P Each part $(D $$(LPAREN)expr$(RPAREN)) of the token which is an $(GLINK
68
+
InterpolationExpression) is translated into the sequence $(D
$(P Types defined in $(D core.interpolation) need not be imported to use IES. These are automatically imported when an IES is used. The types are defined so as to make it easy to introspect the IES for processing at compile-time.)
90
+
$(P Types defined in $(D core.interpolation) need not be imported to use IES.
91
+
These are automatically imported when an IES is used. The types are defined so
92
+
as to make it easy to introspect the IES for processing at compile-time.)
80
93
81
94
$(H3 $(LNAME2 interp_header, InterpolationHeader and InterpolationFooter))
82
95
83
-
$(P The $(D InterpolationHeader) and $(InterpolationFooter) type are empty structs that allow easy overloading of functions to handle IES. They also can be used to understand which parts of a expression list were passed via IES.)
96
+
$(P The $(D InterpolationHeader) and $(InterpolationFooter) type are empty
97
+
structs that allow easy overloading of functions to handle IES. They also can
98
+
be used to understand which parts of a expression list were passed via IES.)
84
99
85
-
$(P These types have a $(D toString) definition that returns an empty string, to allow for processing by functions which intend to convert IES to text, such as $(D std.stdio.writeln) or $(D std.conv.text).)
100
+
$(P These types have a $(D toString) definition that returns an empty string,
101
+
to allow for processing by functions which intend to convert IES to text, such
$(P The $(D InterpolatedLiteral) type is an empty struct that provides compile-time access to the string literal portion of an IES. This type also provides a $(D toString) member function which returns the literal that is used to construct the type.)
106
+
$(P The $(D InterpolatedLiteral) type is an empty struct that provides
107
+
compile-time access to the string literal portion of an IES. This type also
108
+
provides a $(D toString) member function which returns the part of the
$(P The $(D InterpolatedExpression) type is an empty struct that provides compile-time access to the literal that was used to form the following expression. It provides a $(D toString) member function which returns the empty string. It also has an $(D enum expression) member, which is assigned the text that is used to construct the type.)
113
+
$(P The $(D InterpolatedExpression) type is an empty struct that provides
114
+
compile-time access to the literal that was used to form the following
115
+
expression. It provides a $(D toString) member function which returns the empty
116
+
string. It also has an $(D enum expression) member, which is equal to the
$(H2 $(LNAME2 accepting, Accepting and Processing IES))
96
130
97
-
$(P The recommended mechanism to accept IES is to provide a variadic template function to match the various parameters inside the sequence, surrounded by explicit $(D InterpolationHEader) and $(InterpolationFooter) parameters.)
131
+
$(P The recommended mechanism to accept IES is to provide a variadic template
132
+
function to match the various parameters inside the sequence, surrounded by
133
+
explicit $(D InterpolationHEader) and $(InterpolationFooter) parameters.)
@@ -116,7 +153,10 @@ alias result = processIES!i"Here is a type: $(int)";
116
153
117
154
$(H2 $(LNAME2 tostring, Converting to a String))
118
155
119
-
$(P In many cases, it is desirable to convert an IES to a $(D string). In these cases, it is recommended to use the Phobos function $(D std.conv.text) to convert the IES to a $(D string) before passing to the function.)
156
+
$(P In many cases, it is desirable to convert an IES to a $(D string). The
157
+
Phobos function $(D std.conv.text) can convert the IES to a $(D string) for use
158
+
in any context where a string is needed, for instance to assign to a string
159
+
variable, or call a function that accepts a string.)
$(P It is highly recommended for library authors who wish to accept IES to provide an overload that accepts them, rather than rely on $(D std.conv), as this incurs unnecessary allocations. This is especially important where certain types of injection attacks are possible from malicious user-provided data.)
170
+
$(P It is highly recommended for library authors who wish to accept IES to
171
+
provide an overload that accepts them, rather than rely on $(D std.conv), as
172
+
this incurs unnecessary allocations. This is especially important where certain
173
+
types of injection attacks are possible from malicious user-provided data.)
0 commit comments