220 36869 <2a820658-2c83-4614-b871-b19a760faafd@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Todd Fleming <tbfleming@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: String interpolation
Date: Sun, 11 Feb 2018 09:02:26 -0800 (PST)
Lines: 122
Approved: news@gmane.org
Message-ID: <2a820658-2c83-4614-b871-b19a760faafd@isocpp.org>
References: <356d5835-f1bf-4699-94f5-0b2d3d0b9c0e@isocpp.org>
 <CAMD6iD9aT26x8GQHnQL+kuj3Rq8fVQSfYYFtvTnFidkf6jU_ag@mail.gmail.com>
 <25CCF885-86AD-4D51-8F5C-C46376D34DE0@gmail.com> <4890431.TR9UepuQra@tjmaciei-mobl1>
 <CALvx3hac77b6Z=EOWzKqynALi1-352OvY0dnnOer8rN6tfa01g@mail.gmail.com> <1cdb6300-7397-46d7-bce9-62e6e8dac40b@isocpp.org>
 <CAC+0CCOSZHaTA=YPSDU8Add7mE_BYcYPRCmGW8TRPtZhdqL8Hw@mail.gmail.com>
 <4bce681e-e729-4124-9322-69291fdb6678@isocpp.org>
 <f5feb9a0-99d3-433a-ae46-af34c8d00a61@isocpp.org>
 <8e456af5-09c3-461d-8562-30df127e93af@isocpp.org>
 <bd24b702-025a-4b06-976b-559c779851e1@isocpp.org>
 <f63ed807-c5f6-4997-b03f-b4bc16a70982@isocpp.org>
 <28e80709-5ebb-44d2-b26d-22cafd681330@isocpp.org>
 <58edbd0a-fb4c-48dd-8819-6fea7e9c8e39@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_647_1727766916.1518368546672"
X-Trace: blaine.gmane.org 1518368442 31614 195.159.176.226 (11 Feb 2018 17:00:42 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 11 Feb 2018 17:00:42 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDN5JUVZSIFBBI7OQHKAKGQE5UFDCAI@isocpp.org Sun Feb 11 18:00:38 2018
Return-path: <std-proposals+bncBDN5JUVZSIFBBI7OQHKAKGQE5UFDCAI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f197.google.com ([209.85.217.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDN5JUVZSIFBBI7OQHKAKGQE5UFDCAI@isocpp.org>)
	id 1ekuzI-000791-6B
	for gclcip-std-proposals@m.gmane.org; Sun, 11 Feb 2018 18:00:24 +0100
Original-Received: by mail-ua0-f197.google.com with SMTP id y43sf8621969uac.16
        for <gclcip-std-proposals@m.gmane.org>; Sun, 11 Feb 2018 09:02:29 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=P4ZEOb/Pq3UZZRC8dwVeE0gCafCZPYM/JXpxRkJmBOc=;
        b=DKcM30RiC/AuqtLSwWvkxFgQjO972oss7/gEuOjamsPsJnWwpeXKByVdCEY8/51dPw
         la08bnhpPFYOmN5goRukJpeNJ+NYrfQyp5Wf7k/eSxMeo0mCWquQsMnjKPH0WRt5Gg/l
         FqCTkdZ2+wbOeIVFNpmBXRaki020Cm6G8MDlljaTJGl5xTmcbPcJX6IJ4XSlzVc1jYXs
         8tI3+vLMUy2PJG9uRAT0kZsYsuawEZiSg1Aew+5z52+rztjHPkIwJcICDTn6oiRYT/da
         rt+YwL3EVUwdGWW7TkhOX3gjIZHRZUFPWRgFv4obhYT1MU1IPX2eigj4sJ4/m0hXi1Gu
         Kuyw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=P4ZEOb/Pq3UZZRC8dwVeE0gCafCZPYM/JXpxRkJmBOc=;
        b=Aoiy+TKpRDeNpDLbF6QT4jxKo7zvJoQxa5vIhXwTDWdi7uWXjPTKaBbLiNG3RnICZB
         GB5VXRayaIuJb6kHJT1CVqDswlDkM4GXDhSAfSSE+bqBXpbbcT4xDa62yE0k3fSBEpUs
         w8XVX5JnP5HcIK8YGdB73AbWBju08TFfjEzWo1A9bYk44hzLK1W0CgtEmpC0DBt+W+7Y
         n4ooM9KOgz9dfb7iAI4AV/26md6uycCt0J/VMdAzWH83TzdMDyloHH/UPrjRUSAZTUal
         2Gux2Q/YUilYBqtGrDnNLKN6uI3EN5yu8SDeV8C/lxtgK1kGPIMbtMfNW+2dOkELdsKq
         mUIw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=P4ZEOb/Pq3UZZRC8dwVeE0gCafCZPYM/JXpxRkJmBOc=;
        b=N8/Kyo8bqdAPfuJKvY5yhgs17oywn48fkXvTBDJ7cVxKVnkUkmqotjqlTKti7/bphr
         dv3CLthM2EfFu0Z0Frc1+vLbLkVLCH699X2RAGviIUL+JhnAseeW128HCMmzvi9QbI9+
         /KbLEQLXX23xhsluojcJlc45W9BlrOrzGN+QHPHGzsOwNb9boEM3FDsoKAxCoBEoz720
         bj6Ekf0z1ezWWZzFb4jSRbm0snx+xZT5m2te3GUDS5aLz+0fgTx2o5zw6fOXO5BNgkIY
         8qci6uqmMZuokPTrIvTeeEUg/5Q0TEUVjcOIrB4RIenGxMY0p720rRHbF9I121YXe0gq
         b2vQ==
X-Gm-Message-State: APf1xPC8TFwv0B5ar5/+hKW0my0DdCFxUHZGNS/9N7RK01ZfKduMkVHJ
	EqQcOwNsaG+VKZvJcMx3wz7e/w==
X-Google-Smtp-Source: AH8x227FQgcfTRxgItoK5DwIo5vBa0iqEWID4hC6G+GPo2tEzFzlG411I4jjqI5E6mBtJ5Vvgm981A==
X-Received: by 10.159.58.214 with SMTP id q22mr5010485uag.90.1518368549102;
        Sun, 11 Feb 2018 09:02:29 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.158.3 with SMTP id h3ls6215482vke.11.gmail; Sun, 11 Feb
 2018 09:02:27 -0800 (PST)
X-Received: by 10.31.159.216 with SMTP id i207mr406473vke.12.1518368547367;
        Sun, 11 Feb 2018 09:02:27 -0800 (PST)
In-Reply-To: <58edbd0a-fb4c-48dd-8819-6fea7e9c8e39@isocpp.org>
X-Original-Sender: tbfleming@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:36869
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36869>

------=_Part_647_1727766916.1518368546672
Content-Type: multipart/alternative; 
	boundary="----=_Part_648_1218297557.1518368546672"

------=_Part_648_1218297557.1518368546672
Content-Type: text/plain; charset="UTF-8"

On Sunday, February 11, 2018 at 10:45:18 AM UTC-5, Todd Fleming wrote:
>
> On Sunday, February 11, 2018 at 3:35:50 AM UTC-5, Nicol Bolas wrote:
>>
>> For example, let's say I want to use interpolation to process a literal 
>> and store all of the elements in a tuple. We can store each of the 
>> non-literal parts easily enough. But what about the literal parts? You 
>> might say that a `const char*` is good enough, but maybe I want it to be a 
>> `string_view`. To do that with my system, it's as simple as:
>>
>> tuple(F"some string {variable} other string"sv);
>>
>> I have to write precisely *zero code* to make that work.
>>
>
> I'm starting to really love this idea. I've been racking my head on how to 
> get lit-html <https://github.com/Polymer/lit-html>'s simplicity and 
> expressiveness to C++ code compiled to wasm. The way this proposal is going 
> I'd end up with something like this:
>
> auto h = html(F"<div><h1>{title}</h1><p>{text}</p></div>"sv);
>
> Todd
>
>
Expanding on this a bit since Marcin mentioned JS template literals. The 
html function would internally call another function, int 
template_literal(string_view...). template_literal would return a constant 
which is a handle to a JS template literal. Constant because emscripten 
runs wasm through a post processor (binaryen) which can do transforms like 
this prior to running wasm-specific reoptimization.

I believe Nicol's approach gives me the final piece of the puzzle I need to 
pull this off with a convenient syntax. Now if only I had this approach 
today...

Todd

-- 
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/2a820658-2c83-4614-b871-b19a760faafd%40isocpp.org.

------=_Part_648_1218297557.1518368546672
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sunday, February 11, 2018 at 10:45:18 AM UTC-5, Todd Fl=
eming wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">O=
n Sunday, February 11, 2018 at 3:35:50 AM UTC-5, Nicol Bolas wrote:<blockqu=
ote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>For example, let&#39;=
s say I want to use interpolation to process a literal and store all of the=
 elements in a tuple. We can store each of the non-literal parts easily eno=
ugh. But what about the literal parts? You might say that a `const char*` i=
s good enough, but maybe I want it to be a `string_view`. To do that with m=
y system, it&#39;s as simple as:<br><br><div style=3D"background-color:rgb(=
250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:=
1px"><code><div><span style=3D"color:#000">tuple</span><span style=3D"color=
:#660">(</span><span style=3D"color:#000">F</span><span style=3D"color:#080=
">&quot;some string {variable} other string&quot;</span><span style=3D"colo=
r:#000">sv</span><span style=3D"color:#660">);</span></div></code></div><br=
>I have to write precisely <i>zero code</i> to make that work.<br></div></d=
iv></blockquote><div><br></div><div>I&#39;m starting to really love this id=
ea. I&#39;ve been racking my head on how to get=C2=A0<a href=3D"https://git=
hub.com/Polymer/lit-html" target=3D"_blank" rel=3D"nofollow" onmousedown=3D=
"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%=
2FPolymer%2Flit-html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHLwwkL7NWqLnso=
njlzdoVv_ie3Ig&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.g=
oogle.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FPolymer%2Flit-html\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNHLwwkL7NWqLnsonjlzdoVv_ie3Ig&#39;;return true=
;">lit-html</a>&#39;s simplicity and expressiveness to C++ code compiled to=
 wasm. The way this proposal is going I&#39;d end up with something like th=
is:</div><div><br></div><div><div style=3D"background-color:rgb(250,250,250=
);border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wr=
ap:break-word"><code><div><font color=3D"#660066"><span style=3D"color:#008=
">auto</span><span style=3D"color:#000"> h </span><span style=3D"color:#660=
">=3D</span><span style=3D"color:#000"> html</span><span style=3D"color:#66=
0">(</span><span style=3D"color:#000">F</span><span style=3D"color:#080">&q=
uot;&lt;div&gt;&lt;h1&gt;{title}&lt;/h1&gt;&lt;<wbr>p&gt;{text}&lt;/p&gt;&l=
t;/div&gt;&quot;</span><span style=3D"color:#000">sv</span><span style=3D"c=
olor:#660">);</span></font></div></code></div><br>Todd</div><div><br></div>=
</div></blockquote><div><br></div><div>Expanding on this a bit since Marcin=
 mentioned JS template literals. The html function would internally call an=
other function, int template_literal(string_view...). template_literal woul=
d return a constant which is a handle to a JS template literal. Constant be=
cause emscripten runs wasm through a post processor (binaryen) which can do=
 transforms like this prior to running wasm-specific reoptimization.</div><=
div><br></div><div>I believe Nicol&#39;s approach gives me the final piece =
of the puzzle I need to pull this off with a convenient syntax. Now if only=
 I had this approach today...</div><div><br></div><div>Todd</div><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/2a820658-2c83-4614-b871-b19a760faafd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2a820658-2c83-4614-b871-b19a760faafd=
%40isocpp.org</a>.<br />

------=_Part_648_1218297557.1518368546672--

------=_Part_647_1727766916.1518368546672--

.
