Topic: Request for interest. Generating code: how to do better.


Author: =?UTF-8?Q?Germ=C3=A1n_Diago?= <germandiago@gmail.com>
Date: Wed, 7 Sep 2016 09:31:18 -0700 (PDT)
Raw View
------=_Part_22414_1583786164.1473265878915
Content-Type: multipart/alternative;
 boundary="----=_Part_22415_969647099.1473265878916"

------=_Part_22415_969647099.1473265878916
Content-Type: text/plain; charset=UTF-8

Hello everyone,

*Motivation*

C++ has good capabilities for generic programming but is a bit lacking for
code generation if we do not take into account the C preprocessor.
For example, it is impossible to generate code for functions, which is the
real problem that appeared in my code and I show below.

The C preprocessor has been something that we are adviced not to use for a
long time, however, legitimate case for its use still remain.
I will try to explain my problem first, as it appeared in a real program.

*Real use case*

I had two C APIs (backend implemented in C++ but interface is C). Let us
call those APIs *old version* and *new version*. Both APIs are more or less
equivalent. We have around 100 API calls in total.
We must support both APIs in parallel for our customers, but we just want
to maintain one of the families of APIs in our development and generate the
other. We maintain the new API, so my idea was to generate the *old
version* implementation of the calls in terms of the *new version*.

The goal is, to generate, for each existing API call, (simplified) code
that looks like this:

int OldApiCall(int param1, float param2, MyOldApiType * param3) { return
NewApiCall(param1, param2, param3); }

Actually some conversion also happens betwen old and new API types, but
that is irrelevant.

I successfully did it. Nevertheless, I had to use the preprocessor to
generate the parameters expansion and the function arguments.The steps I
followed are roughtly:

1. Create a table with the functions to call:

//Each line contains (ApiName, numOfArgs)
#define FOR_EACH_API(apply)
    apply(ApiName, 1) \
    apply(ApiName2, 3) \
....

2. Use a macro to generate the code (impossible to do without the
preprocessor):

#define GENERATE_CALL(apiname, numOfArgs) \
  FunctionTraits<decltype(&old##apiname), &old##apiname>::ReturnType
old##apiname(BOOST_PP_REPEAT(numOfArgs)blabla... ) { \
          return CallApi<decltype(new##apiname), &new##apiname>(/*generate
params to pass*/); \
  }

3. Generate the code

FOR_EACH_API(GENERATE_CALL)


Problems found:

1. In FOR_EACH_API I need to pass the number of parameters. This can be
deduced by my FunctionTraits template, but at preprocessor time
FunctionTraits<...>::Arity cannot be passed to BOOST_PP_REPEAT, which also
uses the preprocessor.
2. Obvious abuse of macros for generating the code.

*What would need to kill the preprocessor completely?*

It is considered since long ago a bad practice to use the preprocessor.
However, the preprocessor has still legitimate uses:

1. Expanding __FILE__ and __LINE__ in-place. (source_location in
Fundamentals TS2 could solve this).
2. Stringification of arguments. (maybe reflection can solve this?)
3. Configuration. Feature detection is still added in form of feature
macros. There is no equivalent of constexpr if at the namespace scope level
and the only solution is to abuse template specialization at the moment.
4. Code like the use case shown above cannot be expanded at compile-time
without the preprocessor.

With modules coming into the language and modernization of toolchains, it
is even more desirable to get rid of the preprocessor.

*How to solve it for my use case.*

This section is more of a question than a response to my wishes.
Two solutions come to my mind for solving the code generation problem:

1. Exposing the AST in some way and being able to do trickery. I find this
difficult to implement and would need a lot of work.
2. Using a codeof(someConstexprFunction(params...)). This hypothetical
operator would expand code before compilation but after the preprocessor
phase and would have access to all variables, etc. I am thinking of
something similar, maybe the same as https://dlang.org/mixin.html.
3. Any other proposal that comes to mind to any of you.

With solution 2. I could generate the code from a constexpr array or
similar the following way


template <class CTString>
constexpr auto generateApiCall(CTString const & apiCall) {
    auto oldApiName = makeConstString("old") + apiCall;
    auto newApiName = ...;
    auto code = "FunctionTraits<" + ... ;

    return code;
}

template <class CTString, class... CTSTrings>
constexpr auto generateApiCalls(CTString const & apiCall, CTStrings const
&... rest) {
   ...
}

Use to generate all code:

codeof(generateApiCalls("MyApiCall", "MyApiCall2"...));


This would allow to use the code and directly generate it in-place.
A few other things that can be done with this:

- Compile-time regular expressions. (Generate optimized code for a regular
expression depending on string input). This is done suboptimally (the
syntax) with Boost.Xpressive.
- Compile-time string encryption.
- Named tuples. (Generate a struct from string parameters).
- Any EDSL could be done with this extension (SQL, EBNF grammars...
matching real syntax).
- String interpolation of string variable with real variables from the
program.

Let me know what you think and if there would be some interest in a minimal
proposal that can remove the need for my use case.

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/41c7d4ae-5cec-4e09-a3cd-7aee02300b8f%40isocpp.org.

------=_Part_22415_969647099.1473265878916
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello everyone,=C2=A0<div><br></div><div><b><font size=3D"=
4">Motivation</font></b></div><div><br></div><div>C++ has good capabilities=
 for generic programming but is a bit lacking for code generation if we do =
not take into account the C preprocessor.</div><div>For example, it is impo=
ssible to generate code for functions, which is the real problem that appea=
red in my code and I show below.</div><div><br></div><div>The C preprocesso=
r has been something that we are adviced not to use for a long time, howeve=
r, legitimate case for its use still remain.</div><div>I will try to explai=
n my problem first, as it appeared in a real program.</div><div><br></div><=
div><b><font size=3D"4">Real use case</font></b></div><div><b><font size=3D=
"4"><br></font></b></div><div><font size=3D"2">I had two C APIs (backend im=
plemented in C++ but interface is C). Let us call those APIs *old version* =
and *new version*. Both APIs are more or less equivalent. We have around 10=
0 API calls in total.</font></div><div><font size=3D"2">We must support bot=
h APIs in parallel for our customers, but we just want to maintain one of t=
he families of APIs in our development and generate the other. We maintain =
the new API, so my idea was to generate the *old version* implementation of=
 the calls in terms of the *new version*.=C2=A0</font></div><div><font size=
=3D"2"><br></font></div><div><font size=3D"2">The goal is, to generate, for=
 each existing API call, (simplified) code that looks like this:</font></di=
v><div><font size=3D"2"><br></font></div><div><font size=3D"2">int OldApiCa=
ll(int param1, float param2, MyOldApiType * param3) { return NewApiCall(par=
am1, param2, param3); }</font></div><div><font size=3D"2"><br></font></div>=
<div><span style=3D"font-size: small;">Actually some conversion also happen=
s betwen old and new API types, but that is irrelevant.</span><br></div><di=
v><font size=3D"2"><br></font></div><div><font size=3D"2">I successfully di=
d it. Nevertheless, I had to use the preprocessor to generate the parameter=
s expansion and the function arguments.The steps I followed are roughtly:</=
font></div><div><font size=3D"2"><br></font></div><div><font size=3D"2">1. =
Create a table with the functions to call:</font></div><div><font size=3D"2=
"><br></font></div><div><font size=3D"2">//Each line contains (ApiName, num=
OfArgs)</font></div><div><font size=3D"2">#define FOR_EACH_API(apply)</font=
></div><div><font size=3D"2">=C2=A0 =C2=A0 apply(ApiName, 1) \ =C2=A0 =C2=
=A0</font></div><div><font size=3D"2">=C2=A0 =C2=A0 apply(ApiName2, 3) \</f=
ont></div><div><font size=3D"2">...</font></div><div><font size=3D"2"><br><=
/font></div><div><font size=3D"2">2. Use a macro to generate the code (impo=
ssible to do without the preprocessor):</font></div><div><font size=3D"2"><=
br></font></div><div><font size=3D"2">#define GENERATE_CALL(apiname, numOfA=
rgs) \</font></div><div><font size=3D"2">=C2=A0 FunctionTraits&lt;decltype(=
&amp;old##apiname), &amp;old##apiname&gt;::ReturnType old##apiname(BOOST_PP=
_REPEAT(numOfArgs)blabla... ) { \</font></div><div><font size=3D"2">=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return CallApi&lt;decltype(new##apiname), &amp;=
new##apiname&gt;(/*generate params to pass*/); \</font></div><div><font siz=
e=3D"2">=C2=A0 }</font></div><div><font size=3D"2"><br></font></div><div><f=
ont size=3D"2">3. Generate the code</font></div><div><font size=3D"2"><br><=
/font></div><div><font size=3D"2">FOR_EACH_API(GENERATE_CALL)</font></div><=
div><font size=3D"2"><br></font></div><div><font size=3D"2"><br></font></di=
v><div><font size=3D"2">Problems found:</font></div><div><font size=3D"2"><=
br></font></div><div><font size=3D"2">1. In FOR_EACH_API I need to pass the=
 number of parameters. This can be deduced by my FunctionTraits template, b=
ut at preprocessor time</font></div><div><font size=3D"2">FunctionTraits&lt=
;...&gt;::Arity cannot be passed to BOOST_PP_REPEAT, which also uses the pr=
eprocessor.</font></div><div><font size=3D"2">2. Obvious abuse of macros fo=
r generating the code.</font></div><div><br></div><div><div><font size=3D"4=
"><b>What would need to kill the preprocessor completely?</b></font></div><=
/div><div><font size=3D"4"><b><br></b></font></div><div><font size=3D"2">It=
 is considered since long ago a bad practice to use the preprocessor. Howev=
er, the preprocessor has still legitimate uses:</font></div><div><font size=
=3D"2"><br></font></div><div><font size=3D"2">1. Expanding __FILE__ and __L=
INE__ in-place. (source_location in Fundamentals TS2 could solve this).</fo=
nt></div><div><font size=3D"2">2. Stringification of arguments. (maybe refl=
ection can solve this?)</font></div><div><font size=3D"2">3. Configuration.=
 Feature detection is still added in form of feature macros. There is no eq=
uivalent of constexpr if at the namespace scope level and the only solution=
 is to abuse template specialization at the moment.</font></div><div><font =
size=3D"2">4. Code like the use case shown above cannot be expanded at comp=
ile-time without the preprocessor.</font></div><div><font size=3D"2"><br></=
font></div><div>With modules coming into the language and modernization of =
toolchains, it is even more desirable to get rid of the preprocessor.</div>=
<div><br></div><div><font size=3D"4"><b>How to solve it for my use case.</b=
></font></div><div><font size=3D"4"><b><br></b></font></div><div><font size=
=3D"2">This section is more of a question than a response to my wishes.=C2=
=A0</font></div><div><font size=3D"2">Two solutions come to my mind for sol=
ving the code generation problem:</font></div><div><font size=3D"2"><br></f=
ont></div><div><font size=3D"2">1. Exposing the AST in some way and being a=
ble to do trickery. I find this difficult to implement and would need a lot=
 of work.</font></div><div><font size=3D"2">2. Using a codeof(someConstexpr=
Function(params...)). This hypothetical operator would expand code before c=
ompilation but after the preprocessor phase and would have access to all va=
riables, etc. I am thinking of something similar, maybe the same as=C2=A0ht=
tps://dlang.org/mixin.html.</font></div><div>3. Any other proposal that com=
es to mind to any of you.</div><div><br></div><div>With solution 2. I could=
 generate the code from a constexpr array or similar the following way</div=
><div><br></div><div><br></div><div>template &lt;class CTString&gt;</div><d=
iv>constexpr auto generateApiCall(CTString const &amp; apiCall) {</div><div=
>=C2=A0 =C2=A0 auto oldApiName =3D makeConstString(&quot;old&quot;) + apiCa=
ll;</div><div>=C2=A0 =C2=A0 auto newApiName =3D ...;</div><div>=C2=A0 =C2=
=A0 auto code =3D &quot;FunctionTraits&lt;&quot; + ... ;</div><div>=C2=A0 =
=C2=A0=C2=A0</div><div>=C2=A0 =C2=A0 return code;</div><div>}</div><div><br=
></div><div><div>template &lt;class CTString, class... CTSTrings&gt;</div><=
div>constexpr auto generateApiCalls(CTString const &amp; apiCall, CTStrings=
 const &amp;... rest) {</div><div>=C2=A0 =C2=A0...</div><div>}</div></div><=
div><br></div><div>Use to generate all code:</div><div><br></div><div>codeo=
f(generateApiCalls(&quot;MyApiCall&quot;, &quot;MyApiCall2&quot;...));</div=
><div><font size=3D"2"><br></font></div><div><font size=3D"2">=C2=A0</font>=
</div><div><font size=3D"2">This would allow to use the code and directly g=
enerate it in-place.</font></div><div><font size=3D"2">A few other things t=
hat can be done with this:</font></div><div><font size=3D"2"><br></font></d=
iv><div><font size=3D"2">- Compile-time regular expressions. (Generate opti=
mized code for a regular expression depending on string input). This is don=
e suboptimally (the syntax) with Boost.Xpressive.</font></div><div><font si=
ze=3D"2">- Compile-time string encryption.=C2=A0</font></div><div><font siz=
e=3D"2">- Named tuples. (Generate a struct from string parameters).</font><=
/div><div><font size=3D"2">- Any EDSL could be done with this extension (SQ=
L, EBNF grammars... matching real syntax).</font></div><div><font size=3D"2=
">- String interpolation of string variable with real variables from the pr=
ogram.</font></div><div><font size=3D"2"><br></font></div><div><font size=
=3D"2">Let me know what you think and if there would be some interest in a =
minimal proposal that can remove the need for my use case.</font></div><div=
><font size=3D"2"><br></font></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/41c7d4ae-5cec-4e09-a3cd-7aee02300b8f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/41c7d4ae-5cec-4e09-a3cd-7aee02300b8f=
%40isocpp.org</a>.<br />

------=_Part_22415_969647099.1473265878916--

------=_Part_22414_1583786164.1473265878915--

.


Author: =?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?= <mjklaim@gmail.com>
Date: Sat, 10 Sep 2016 11:43:22 +0200
Raw View
--001a114124a803a0a7053c2418c3
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 7 September 2016 at 18:31, Germ=C3=A1n Diago <germandiago@gmail.com> wro=
te:

> *How to solve it for my use case.*
>
> This section is more of a question than a response to my wishes.
> Two solutions come to my mind for solving the code generation problem:
>
> 1. Exposing the AST in some way and being able to do trickery. I find thi=
s
> difficult to implement and would need a lot of work.
>

There was a proposal (maybe unpublished) that was discussed in the
reflection work group for that.
To be short, it was not acceptable to either have another new language to
express the AST
and if my memory is correct, the guidelines for reflection were clarified
since that they do not want to expose the implementation in the language.


> 2. Using a codeof(someConstexprFunction(params...)). This hypothetical
> operator would expand code before compilation but after the preprocessor
> phase and would have access to all variables, etc. I am thinking of
> something similar, maybe the same as https://dlang.org/mixin.html.
> 3. Any other proposal that comes to mind to any of you.
>
>
Well the currently leading static reflection proposal could reach a
solution IFF the code generation extensions gets voted in.
See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0194r0.pdf
and http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0385r0.pdf

[...]

> This would allow to use the code and directly generate it in-place.
> A few other things that can be done with this:
>
> - Compile-time regular expressions. (Generate optimized code for a regula=
r
> expression depending on string input). This is done suboptimally (the
> syntax) with Boost.Xpressive.
>
- Compile-time string encryption.
>

My understanding is that both have been done already using (or exploiting)
constexpr.
Also, compile-time string hashes.


> - Named tuples. (Generate a struct from string parameters).
>

If I remember correctly, there are several proposals related to different
parts of the language that would lead to this.


> - Any EDSL could be done with this extension (SQL, EBNF grammars...
> matching real syntax).
>

I believe we already have libraries being very close to that?


> - String interpolation of string variable with real variables from the
> program.
>
>
Interpolation? I'm not sure what you mean here.

Jo=C3=ABl Lamotte

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAOU91OOWZJyLHBJhTMjGG94NqjormwZa5PwqFqpRQqTWSCL=
%2Bvg%40mail.gmail.com.

--001a114124a803a0a7053c2418c3
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On 7 September 2016 at 18:31, Germ=C3=A1n Diago <span dir=3D"ltr">&lt;<=
a href=3D"mailto:germandiago@gmail.com" target=3D"_blank">germandiago@gmail=
..com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:=
1ex"><div dir=3D"ltr"><div><font size=3D"4"><b>How to solve it for my use c=
ase.</b></font></div><div><font size=3D"4"><b><br></b></font></div><div><fo=
nt size=3D"2">This section is more of a question than a response to my wish=
es.=C2=A0</font></div><div><font size=3D"2">Two solutions come to my mind f=
or solving the code generation problem:</font></div><div><font size=3D"2"><=
br></font></div><div><font size=3D"2">1. Exposing the AST in some way and b=
eing able to do trickery. I find this difficult to implement and would need=
 a lot of work.</font></div></div></blockquote><div><br></div><div>There wa=
s a proposal (maybe unpublished) that was discussed in the reflection work =
group for that.</div><div>To be short, it was not acceptable to either have=
 another new language to express the AST</div><div>and if my memory is corr=
ect, the guidelines for reflection were clarified since that they do not wa=
nt to expose the implementation in the language.</div><div>=C2=A0</div><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div><font s=
ize=3D"2">2. Using a codeof(someConstexprFunction(<wbr>params...)). This hy=
pothetical operator would expand code before compilation but after the prep=
rocessor phase and would have access to all variables, etc. I am thinking o=
f something similar, maybe the same as=C2=A0<a href=3D"https://dlang.org/mi=
xin.html" target=3D"_blank">https://dlang.org/mixin.<wbr>html</a>.</font></=
div><div>3. Any other proposal that comes to mind to any of you.</div><div>=
<br></div></div></blockquote><div><br></div><div>Well the currently leading=
 static reflection proposal could reach a solution IFF the code generation =
extensions gets voted in.</div><div>See=C2=A0<a href=3D"http://www.open-std=
..org/jtc1/sc22/wg21/docs/papers/2016/p0194r0.pdf">http://www.open-std.org/j=
tc1/sc22/wg21/docs/papers/2016/p0194r0.pdf</a></div><div>and=C2=A0<a href=
=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0385r0.pdf">ht=
tp://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0385r0.pdf</a></div>=
<div>=C2=A0</div><div>[...]=C2=A0</div><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padd=
ing-left:1ex"><div dir=3D"ltr"><div><font size=3D"2">This would allow to us=
e the code and directly generate it in-place.</font></div><div><font size=
=3D"2">A few other things that can be done with this:</font></div><div><fon=
t size=3D"2"><br></font></div><div><font size=3D"2">- Compile-time regular =
expressions. (Generate optimized code for a regular expression depending on=
 string input). This is done suboptimally (the syntax) with Boost.Xpressive=
..</font>=C2=A0</div></div></blockquote><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padd=
ing-left:1ex"><div dir=3D"ltr"><div><font size=3D"2">- Compile-time string =
encryption.=C2=A0</font></div></div></blockquote><div><br></div><div>My und=
erstanding is that both have been done already using (or exploiting) conste=
xpr.</div><div>Also, compile-time string hashes.</div><div>=C2=A0</div><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div><font s=
ize=3D"2">- Named tuples. (Generate a struct from string parameters).</font=
></div></div></blockquote><div><br></div><div>If I remember correctly, ther=
e are several proposals related to different parts of the language that wou=
ld lead to this.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padd=
ing-left:1ex"><div dir=3D"ltr"><div><font size=3D"2">- Any EDSL could be do=
ne with this extension (SQL, EBNF grammars... matching real syntax).</font>=
</div></div></blockquote><div><br></div><div>I believe we already have libr=
aries being very close to that?</div><div>=C2=A0</div><blockquote class=3D"=
gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(20=
4,204,204);padding-left:1ex"><div dir=3D"ltr"><div><font size=3D"2">- Strin=
g interpolation of string variable with real variables from the program.</f=
ont></div><div><font size=3D"2"><br></font></div></div></blockquote><div><b=
r></div><div>Interpolation? I&#39;m not sure what you mean here.=C2=A0</div=
><div><br></div><div>Jo=C3=ABl Lamotte</div></div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOU91OOWZJyLHBJhTMjGG94NqjormwZa5Pwq=
FqpRQqTWSCL%2Bvg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOU91OOWZJyLHB=
JhTMjGG94NqjormwZa5PwqFqpRQqTWSCL%2Bvg%40mail.gmail.com</a>.<br />

--001a114124a803a0a7053c2418c3--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sat, 10 Sep 2016 07:38:28 -0700 (PDT)
Raw View
------=_Part_442_1662581614.1473518308150
Content-Type: multipart/alternative;
 boundary="----=_Part_443_1684498125.1473518308150"

------=_Part_443_1684498125.1473518308150
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Saturday, September 10, 2016 at 5:43:25 AM UTC-4, Klaim - Jo=C3=ABl Lamo=
tte=20
wrote:
>
> - String interpolation of string variable with real variables from the=20
>> program.
>>
>>
> Interpolation? I'm not sure what you mean here.
>

You know how Perl allows you to do this:

"text $varName more text"

This causes the interpreter to substitute `$varName` and replace it with=20
whatever is in that variable at runtime, thus making it easier to embed the=
=20
contents of a variable in a string.

That concept is generally called "string interpolation".

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/7b9efc3e-791b-4b98-a247-1b3dda9186fc%40isocpp.or=
g.

------=_Part_443_1684498125.1473518308150
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Saturday, September 10, 2016 at 5:43:25 AM UTC-4, Klaim=
 - Jo=C3=ABl Lamotte wrote:<blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><di=
v dir=3D"ltr"><div><div class=3D"gmail_quote"><div></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div><font size=3D"2">- S=
tring interpolation of string variable with real variables from the program=
..</font></div><div><font size=3D"2"><br></font></div></div></blockquote><di=
v><br></div><div>Interpolation? I&#39;m not sure what you mean here.</div><=
/div></div></div></blockquote><div><br>You know how Perl allows you to do t=
his:<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, =
250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-wi=
dth: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D=
"subprettyprint"><span style=3D"color: #080;" class=3D"styled-by-prettify">=
&quot;text $varName more text&quot;</span></div></code></div><br>This cause=
s the interpreter to substitute `$varName` and replace it with whatever is =
in that variable at runtime, thus making it easier to embed the contents of=
 a variable in a string.<br><br>That concept is generally called &quot;stri=
ng interpolation&quot;.<br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/7b9efc3e-791b-4b98-a247-1b3dda9186fc%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7b9efc3e-791b-4b98-a247-1b3dda9186fc=
%40isocpp.org</a>.<br />

------=_Part_443_1684498125.1473518308150--

------=_Part_442_1662581614.1473518308150--

.


Author: =?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?= <mjklaim@gmail.com>
Date: Sun, 11 Sep 2016 12:27:23 +0200
Raw View
--001a1142bdb24d0e00053c38d3ed
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 10 September 2016 at 16:38, Nicol Bolas <jmckesson@gmail.com> wrote:

> On Saturday, September 10, 2016 at 5:43:25 AM UTC-4, Klaim - Jo=C3=ABl La=
motte
> wrote:
>>
>> - String interpolation of string variable with real variables from the
>>> program.
>>>
>>>
>> Interpolation? I'm not sure what you mean here.
>>
>
> You know how Perl allows you to do this:
>
> "text $varName more text"
>
> This causes the interpreter to substitute `$varName` and replace it with
> whatever is in that variable at runtime, thus making it easier to embed t=
he
> contents of a variable in a string.
>
> That concept is generally called "string interpolation".
>

Ah ok thanks, I didn't know it had a name.


> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/7b9efc3e-791b-4b98-
> a247-1b3dda9186fc%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b9efc3e-79=
1b-4b98-a247-1b3dda9186fc%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAOU91OPsNj7UPr7G14gd6jjvVzv31xtGMj_r6E3v3uJzFLF=
N2A%40mail.gmail.com.

--001a1142bdb24d0e00053c38d3ed
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
On 10 September 2016 at 16:38, Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D=
"mailto:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>&gt;<=
/span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span clas=
s=3D"">On Saturday, September 10, 2016 at 5:43:25 AM UTC-4, Klaim - Jo=C3=
=ABl Lamotte wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;marg=
in-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"=
><div><div class=3D"gmail_quote"><div></div><blockquote class=3D"gmail_quot=
e" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)=
;padding-left:1ex"><div dir=3D"ltr"><div><font size=3D"2">- String interpol=
ation of string variable with real variables from the program.</font></div>=
<div><font size=3D"2"><br></font></div></div></blockquote><div><br></div><d=
iv>Interpolation? I&#39;m not sure what you mean here.</div></div></div></d=
iv></blockquote></span><div><br>You know how Perl allows you to do this:<br=
><br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,1=
87,187);border-style:solid;border-width:1px;word-wrap:break-word"><code><di=
v><span style=3D"color:#080">&quot;text $varName more text&quot;</span></di=
v></code></div><br>This causes the interpreter to substitute `$varName` and=
 replace it with whatever is in that variable at runtime, thus making it ea=
sier to embed the contents of a variable in a string.<br><br>That concept i=
s generally called &quot;string interpolation&quot;.<br></div></div></block=
quote><div><br></div><div>Ah ok thanks, I didn&#39;t know it had a name.</d=
iv><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div></=
div></div><span class=3D"">

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/7b9efc3e-791b-4b98-a247-1b3dda9186fc%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/7b9e=
fc3e-791b-4b98-<wbr>a247-1b3dda9186fc%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOU91OPsNj7UPr7G14gd6jjvVzv31xtGMj_r=
6E3v3uJzFLFN2A%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOU91OPsNj7UPr7G=
14gd6jjvVzv31xtGMj_r6E3v3uJzFLFN2A%40mail.gmail.com</a>.<br />

--001a1142bdb24d0e00053c38d3ed--

.