220 36940 <CANaF6iikVH-jjGFxx2whvec=wcRPeXDwTZSevxD9anWhY9zh0g@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Florian Lemaitre <florian.csdt@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: String interpolation
Date: Fri, 16 Feb 2018 10:18:37 +0100
Lines: 827
Approved: news@gmane.org
Message-ID: <CANaF6iikVH-jjGFxx2whvec=wcRPeXDwTZSevxD9anWhY9zh0g@mail.gmail.com>
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> <758ab0a7-8946-43d4-b2ae-5a4acea11c20@isocpp.org>
 <CAC+0CCOovuF+HGepUDQVjkSJoCbGHBNcemaUU9h_gBUPD9ns+w@mail.gmail.com>
 <CAFQaeCBywEdaj1MD0bpyxcjXRkF1jGaCOcpk=4vHtSjEbYbcJw@mail.gmail.com>
 <01057924-056c-4ee5-a19c-e070d053b982@isocpp.org> <CAC+0CCM0SLuJk3GPA-zqb_X7z-kY_tNF1iLnOocLJwP9eErnLQ@mail.gmail.com>
 <c74fcb96-ed06-4360-bedf-e902b000b13b@isocpp.org> <3a738e91-f935-4d11-ab6b-771048b556d4@isocpp.org>
 <96860b9e-95ea-466a-825c-c371844a45e2@isocpp.org> <0caab177-cf57-cab1-a5d5-0fc65f651491@gmail.com>
 <7b1c3d63-d534-44d2-b4e9-fc0df135fff5@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="001a114bb2645977e5056550d40c"
X-Trace: blaine.gmane.org 1518772638 32229 195.159.176.226 (16 Feb 2018 09:17:18 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 16 Feb 2018 09:17:18 +0000 (UTC)
Cc: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
To: Nicol Bolas <jmckesson@gmail.com>
Original-X-From: std-proposals+bncBC26HM4V3MIRB3WDTLKAKGQEGCFAL3Y@isocpp.org Fri Feb 16 10:17:14 2018
Return-path: <std-proposals+bncBC26HM4V3MIRB3WDTLKAKGQEGCFAL3Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qt0-f200.google.com ([209.85.216.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC26HM4V3MIRB3WDTLKAKGQEGCFAL3Y@isocpp.org>)
	id 1emc8A-0005ga-26
	for gclcip-std-proposals@m.gmane.org; Fri, 16 Feb 2018 10:16:34 +0100
Original-Received: by mail-qt0-f200.google.com with SMTP id s42sf2014693qta.23
        for <gclcip-std-proposals@m.gmane.org>; Fri, 16 Feb 2018 01:18:40 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1518772719; cv=pass;
        d=google.com; s=arc-20160816;
        b=L/NTwioIV/Ct6/pVAQP8iDoeF+Vv0VBId3xwcrp/3dGcMKRAqo5azPlkzNtyPUSqZ6
         JchH/DJb2hdQwY44x/i+t4pV85B0nsebDnzjIt1jY3ZXh8G7O5MLHWkV+VIK4sepfkbi
         P6Jb/ajXQ2gC6S3LTLRnwgjlI4WFQ/8bQxgWs8BSRo/GxH5Gmi3JYm2OcVyRbqLoC8T8
         +ez2jcnQRFWnLNct6fpPLG6jwn2gtZljCIrZZh0lTotQlrjdjCEefhGJzyZ63VmMhxct
         RD2ssCuE0W6mXnkKIgxC+xPNwCMeLkazq9ivGtogmLZ1u6iH85D7vAdO+BaMleOOabK7
         zSnQ==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:cc:to:subject:message-id
         :date:from:references:in-reply-to:mime-version
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=GiBJbfg9CeCtbWPLzvhtBxpNZFLyZAp19BLR3wJKf2U=;
        b=ocwSSUZnQKYTSloRGRvRyOsz1qNIEJxASZGPbRr8+3S5yvt1Ywz7h8Ybx5Dktni2lQ
         BAYvb09r0wv6/2Kcr50+FGdq2oEF0+zhAfKSnua23K8eZt6At9zjth+7GZUouVV+13kA
         ooF357KOCBCJLrII8t3G6Pn6fedryT4U/udMt34/dfCKjXG6FzjzgkZ0D/oHePqBiiKC
         skg1Rypt1/0L0t0qh/c/Rpt8AWHVprmmAwoNSVeQf/uJC1+XoE+IGLCbjntzXNrixWSf
         FLT6+SFGwxG2zpKqrOaemNO8oY7p+HiA5+I6fiHN60kXhD/QKKL25xwPlNqFzTOtB7md
         ox6Q==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=PJr8V4BL;
       spf=pass (google.com: domain of florian.csdt@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=florian.csdt@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :cc:x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=GiBJbfg9CeCtbWPLzvhtBxpNZFLyZAp19BLR3wJKf2U=;
        b=geuFchiPOWJ+BPXB2Zx0NLeWj9wxUPiefFR1nrw8T7HQNKNqEwaOxHjlVwPrvhxits
         CuGrXT372n5idj2IQA638YH//HssqTsz/olBvT7vtL3mnY6JMyUg4T8tItPyxzED02bI
         T2OimBzrnm4dea7dm/QH/1azmmMfdmGuDIJcgcOJVxxYGanRlsZkzFbSVi/EzO18vCWK
         MnpOzSJ32Cc+gksUqp8WYu/okhab6oG30lW2buqnIZMkWBAMNXmHq3AYX2NLebFpBTVU
         0enNaGuSM9q4r4xJ1FQNKuKw83AOdU4T4OTeR2XDCSir0S5nytsE++JirspamSsAVzq6
         y0AA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:cc:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=GiBJbfg9CeCtbWPLzvhtBxpNZFLyZAp19BLR3wJKf2U=;
        b=fhiB1vvJgz2uxYU4w6emVtne/5FkgVQ4grNNKc+NQ5h1y/qGL0L9XJdQu50mJGGap9
         XOu80m1rMGHoi9OhEmpjLZjb8AbivIrhgA5sTTIek1npScwPjO0fRmIwo0fx3ENOzT75
         pelQ3YifacW60JISZRfBPG6BYHJoovb+Bml0UkVM52xeEi272/mJVctAP7ffQqO/pVOu
         BjT0MEn7bV9oSVTnSllQv3kKNZcVOB8QqLLZlEqcnlRKS1ylwOaS6Ajq4pf4AahC5jod
         tZdm4TbWakfj5oVCob14tDVsVq2z3chH+TP0/W6K9s6xC+DQwXfBYJ8sJXI3NF+TsMxK
         vSOw==
X-Gm-Message-State: APf1xPA4VTkjRrfJDDIRB/rsqKRnTPk+HIlITGNsiyoaRa2U30PWnxtQ
	3x9GGnqvpGxmpYtTFN6/4nx6LA==
X-Google-Smtp-Source: AH8x225iu0/7p7poe78yttAVBn2UCCT+gHe6yZ6nZJAIb/8+0vLOJM9oRyEMM01hqHT9OQVD0ARbvg==
X-Received: by 10.55.27.27 with SMTP id b27mr3861603qkb.53.1518772719677;
        Fri, 16 Feb 2018 01:18:39 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.200.9.79 with SMTP id z15ls1136944qth.0.gmail; Fri, 16 Feb
 2018 01:18:38 -0800 (PST)
X-Received: by 10.237.53.40 with SMTP id a37mr9135406qte.96.1518772718439;
        Fri, 16 Feb 2018 01:18:38 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1518772718; cv=none;
        d=google.com; s=arc-20160816;
        b=QwID2O191fXLiIhwMT491mMjndz0NK/Gd0zbRDM5lxobJGkl5jbA8IFztS4Zchn9B9
         HZL8qCOxyCQr5a2PeJKc891MPAMC7tJEP1PeKwT9tMXMmyjh+BrzmDsyveke/e4RSfIj
         bPrUp2l89KyUr+0eG0E5C855qKeDo+zwmss9PmDqULC0QoC+mQQkppHaWs8DYnnXSbz1
         V/pwNJkbCI9CjZLGcnJ5XP5Ik1Xni7TrxKNWR/unTB0/r8lLNPNNAs2hP6PugT7jOLKh
         1R95Ewpfck1NDHbYrTnn9pYOX2zJmOBGMnJ5hGJAze8/dfe4DbROO7GOgpLf2ErbzCiX
         aNnQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=cc:to:subject:message-id:date:from:references:in-reply-to
         :mime-version:dkim-signature:arc-authentication-results;
        bh=N0275FAPdlLbuQ3UXTBoJYzajl0sZoH0ilvtL1dyQGw=;
        b=RuBDk7m73T9j3dKKiNCMZNc8WmxHCc4tuFqcpMvz3czaMzS0/dbws/8uHD9Tt2RNLU
         892tmvMrfR5WV2TPbl4EdvYJEmRxbc9WG2L/VcG6nsAt2k/2nDlX3x+p8qo94iqAK5Z6
         TbHhFsbqAQitMB3hyjLE7kNYsvIEqVaBtiL8s9c+u7RDTwsKW/inpZ8uZ+MdfExoW2WR
         o72XvNTQkIpw7Q5SlM0IcanD2jK1mLaF6Vc9KM6FQ4JZdgZnoDYlMXZnf1fxyuR5+JSQ
         nhhdLNxo6Sc2ZXbwGnGs1+ruoWIU+RX0fzIvoh+N+Y1o+qefRcuxYBlbq/pRM2A/gU8U
         wZ8w==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=PJr8V4BL;
       spf=pass (google.com: domain of florian.csdt@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=florian.csdt@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65])
        by mx.google.com with SMTPS id n29sor1564270qtl.18.2018.02.16.01.18.38
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Fri, 16 Feb 2018 01:18:38 -0800 (PST)
Received-SPF: pass (google.com: domain of florian.csdt@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65;
X-Received: by 10.200.15.81 with SMTP id l17mr9052904qtk.45.1518772717974;
 Fri, 16 Feb 2018 01:18:37 -0800 (PST)
Original-Received: by 10.200.54.162 with HTTP; Fri, 16 Feb 2018 01:18:37 -0800 (PST)
In-Reply-To: <7b1c3d63-d534-44d2-b4e9-fc0df135fff5@isocpp.org>
X-Original-Sender: florian.csdt@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=PJr8V4BL;       spf=pass
 (google.com: domain of florian.csdt@gmail.com designates 209.85.220.65 as
 permitted sender) smtp.mailfrom=florian.csdt@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE dis=NONE) header.from=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:36940
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36940>

--001a114bb2645977e5056550d40c
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

2018-02-16 2:32 GMT+01:00 Nicol Bolas <jmckesson@gmail.com>:

>
>
> On Thursday, February 15, 2018 at 5:54:14 PM UTC-5, Florian Lemaitre wrot=
e:
>>
>> On 15/02/2018 20:39, Nicol Bolas wrote:
>>
>> On Thursday, February 15, 2018 at 11:33:26 AM UTC-5, floria...@gmail.com
>> wrote:
>>>
>>> Le jeudi 15 f=C3=A9vrier 2018 17:19:29 UTC+1, Nicol Bolas a =C3=A9crit =
:
>>>>
>>>> On Thursday, February 15, 2018 at 11:06:10 AM UTC-5, Jake Arkinstall
>>>> wrote:
>>>>>
>>>>> On 15 Feb 2018 15:51, "Nicol Bolas" <jmck...@gmail.com> wrote:
>>>>>
>>>>> Taking a literal (or possibly constexpr string?)
>>>>>
>>>>>
>>>>> I was wondering whether it makes sense to even describe these things
>>>>> as literals, given that they aren't literal and given that they aren'=
t
>>>>> intended to actually be stored in memory in any way.
>>>>>
>>>>
>>>> We still call literals "literals", even if you use them entirely at
>>>> compile-time via `constexpr` tricks, such that no runtime code ever ne=
eds
>>>> them. Things between quotes are literals.
>>>>
>>>> But in terms of constexpr strings, I guess these things themselves can
>>>>> be built up by other methods - I'm not sure if this makes sense in
>>>>> compilation, though; I'm under the impression that the expression its=
elf
>>>>> would likely need to be processed before the constexpr methods themse=
lves
>>>>> could be evaluated (especially given that they could themselves utili=
se
>>>>> interpolation). I could be wrong.
>>>>>
>>>>> I think, at this point, interpolation is a bad word - it made sense i=
n
>>>>> the initial form, but now this has generalised we might want a new wo=
rd for
>>>>> it.
>>>>>
>>>>
>>>> I don't agree. "String interpolation" often carries the connotation
>>>> that you're just going to concatenate strings, but it doesn't *have*
>>>> to. C++ sometimes defines concepts with names that are similar to othe=
r
>>>> language features, but in a more open and freeform way. Lambdas for ex=
ample
>>>> don't have lexical scoping in C++ unless you explicitly ask for them,
>>>> whereas most languages give it to you as a matter of course.
>>>>
>>>> (or possibly arbitrary expressions?)
>>>>>
>>>>>
>>>>> This wouldn't be so much of a problem, because those expressions
>>>>> (other than their declarations) don't need to be completely understoo=
d when
>>>>> the [insert better name for interpolation] is performed - just the
>>>>> resulting type is needed.
>>>>>
>>>>
>>>> The issue with "arbitrary expression" is that you're now requiring the
>>>> compiler to *invoke the compiler*. It's easy for the compiler to take
>>>> a compile-time string and find a variable in scope that matches it. It=
's
>>>> much harder (presumably) for the compiler to take a compile-time strin=
g and
>>>> invoke the compiler on it, within the current scope as if it had been
>>>> written text.
>>>>
>>>> I'm not saying its impossible; I don't know much about compiler
>>>> architecture. But I can't imagine it's as easy as just finding a varia=
ble
>>>> with that name.
>>>>
>>>> Not only that, once you get into wanting `constexpr` strings that can
>>>> be interpolated, you get into lots of issues. Do you really want a fea=
ture
>>>> where you're able to synthesize arbitrary expressions and have someone
>>>> insinuate them into their code at compile time?
>>>>
>>>> Or... maybe you do?
>>>>
>>>
>>> From what I know about compilation and formal languages in general, it
>>> shouldn't be very hard for a compiler to deal with expressions within
>>> `F"{}"`.
>>> The compiler already do that kind of stuff with parentheses. Compilers
>>> are by nature recursive.
>>>
>>
>> You don't seem to be fully understanding what we're talking about. This
>> isn't standard recursive-descent recursion. This is "execute some conste=
xpr
>> code and then run the compiler on part of its string results." Those
>> "results" might include things like *macros*, and macro expansion is
>> supposed to have happened long before executing constexpr functions.
>>
>> And you can't just say they're expressions minus macros. Many C-standard
>> library facilities are, or might be, macros after all. Is it legal to do
>> `F"{sin(foo)}"`? If string interpolation is supposed to allow arbitrary
>> expressions, it would be odd indeed if it were not. What about invoking
>> `offsetof` or similar C-isms?
>>
>> If we're only going to allow string interpolation with genuine literals,
>> then this isn't much of a problem. Even the macro issue can be sorted ou=
t,
>> since the string is right there in the text of the source code.
>>
>> But if we want string interpolation to ever be applied to the results of
>> compile-time execution, that's going to be *much* more complex if string
>> interpolation can handle arbitrary expressions. Whereas if we define it =
to
>> just be variable identifiers, extending such interpolation to constexpr
>> strings would be much more reasonable.
>>
>> I would say that any proposal should be focused on the minimum
>> featureset. It should naturally include expanding into arbitrary
>> expressions and constexpr strings as future directions things could take=
,
>> but I wouldn't push for them in the short term. Sort of like how
>> `constexpr` functions in C++11 were really limited, which C++14 greatly
>> expanded.
>>
>> The only thing I don't know is if the compiler deals with string literal=
s
>>> as a single token or not. If they do, string literal parser will have t=
o be
>>> modified quite a lot, even with the "identifier-only" variant.
>>>
>>
>> First thing first, currently the C++ is oblivious to the preprocessor,
>> and this will probably not change in the forseeable future (note that th=
e
>> preprocessor is somehow aware of C++: __cplusplus macro, #include,
>> __has_cpp_attribute...).
>> But as far as the compiler is concerned, these are two distinct steps
>> that are processed one after the other, without going back.
>>
>> Maybe you want to change that, but I think you were mentionning macros
>> taking effect within F"{}".
>>
>
> No, I'm mentioning macros taking effect within *string interpolation*.
>
> We're talking about the intersection of two things, both of which are
> still in question:
>
> 1) Arbitrary expressions in interpolation operations.
> 2) The use of constexpr strings as the *source* for interpolation
> operations; as the string to be interpolated. That is:
>
> constexpr constexpr_string<char> my_func()
> {
>   constexpr_string<char> a =3D "here's a string {sin(5)}"; //Note: not
> doing interpolation.
>   constexpr_string<char> b =3D " more {foo} string"; //Still not
> interpolating.
>   return a + b;
> }
>
> auto str =3D std::concat(<interpolation syntax> my_func());
>
> //The above is equivalent to:
>
> auto str =3D std::concat("here's a string", sin(5), " more ", foo, " stri=
ng"
> );
>
> It's the *combination* of these two things that doesn't work. By the time
> the compiler gets around to actually processing the `my_func` call, macro
> expansion has come and gone. So how does `sin(5)` get expanded properly?
>
> And I know you're thinking that constexpr strings don't exist, that
> they're not even really possible. Yet; the committee is working on
> expansions to constexpr that allow memory allocation. Once that happens, =
we
> will have constexpr strings. And once we do, there's no reason you should
> prevent constexpr strings from being the source of interpolation operatio=
ns.
>
> Well, no reason unless you sandbag interpolation by requiring it to allow
> arbitrary expressions. My feeling is that you have to pick one or the
> other: you either allow arbitrary expressions or you allow constexpr stri=
ng
> interpolation. And if we can only have one, I'd much rather have the latt=
er.
>
> I want constexpr strings to be equivalent to literals as much as possible=
..
>
> I get your problem now.
Just to simplify my explanations, let's assume that string interpolation is
done via a prefix operator called $.

You want to be able to call $ on any constexpr string, and also it would be
nice to also have expressions in the interpolation pattern. But as you
said, having both would trigger the compiler on compiler output, and this
would be difficult to handle.
I now agree with you on the complexity of having both.

What you're describing here looks like some compile-time "eval".
constexpr auto call_foo =3D "{foo()}";

// eval:
$ call_foo;
// translated to:
foo();

This looks nasty.
It would be possible to leak local variables:
int super_private_copy;

auto foo(/*whatever equivalent to string literal*/ s) {
  int super_private =3D 5;
  return std::concat($ s);
}

void bar() {
  foo("{super_private_copy =3D super_private}");
  std::cout << "super_private: " << super_private_copy << std::endl;
}

This little fictive example shows how this would be possible with those
assumptions. And this intrinsically bad, independently to the
implementation complexity.
The outer world should not affect a private scope without its consent. (so
this does not apply if some global is used within the private scope: in
that case, the access to the global is consented by the private scope)


So definitely, having both string interpolation pattern from constexpr
strings *and* expressions can be interpolated is conceptually bad.

So let's consider only string interpolation pattern from constexpr strings.
This also breaks private scope (more tricky though).
// intended to use access1, access2, access3 or access4 as pattern
auto foo(/*whatever equivalent to string literal*/ s) {
  int super_secret =3D 5;
  int access1 =3D 1;
  int access2 =3D 2;
  int access3 =3D 3;
  int access4 =3D 4;
  return std::make_tuple($ s);
}

void bar() {
  auto super_secret =3D std::get<0>(foo("{super_secret}"));
  std::cout << "super_secret: " << super_secret << std::endl;
}

Yes, this example is more convoluted, but it still shows what is possible
to do.

Another thing that could be a problem: what happens if a variable is not
declared? It probably should not compile.
But then we could have pretty complex and hard to debug code:
constexpr auto foo(int i); // returns a "string literal"-like that has the
form "{foo###}" where ### is the i-th prime number

void bar() {
  int foo3 =3D 0;
  do_whatever($ foo(2));
} // This compiles

void baz() {
  int foo4 =3D 0;
  do_whatever($ foo(2));
} // This doesn't compile (obviously)

Why is it different than just access a global variable with the right name?
There is no way to know what variables are needed in order to compile other
than trying to compile the program.
The identifier foo3 is never defined, and never appears in the code (except
within your function).
Moreover, your local scope now is entangled with the value returned by
foo(). (this kind of breaks encapsulation of the local scope)

Maybe your fine with this one, but I'm not. That's why I think string
interpolation should not apply to constexpr strings (at least, not the
interpolation pattern).

Don't get me wrong: I am perfectly fine to standardize only string
interpolation on actual string literal with only identifiers in patterns,
and see later how to improve it.
But as far as I'm concerned, I think interpolating constexpr patterns is a
bad idea and I would much prefer arbitrary expressions to be interpolated.

--=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/CANaF6iikVH-jjGFxx2whvec%3DwcRPeXDwTZSevxD9anWhY=
9zh0g%40mail.gmail.com.

--001a114bb2645977e5056550d40c
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">=
2018-02-16 2:32 GMT+01:00 Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D"mail=
to:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>&gt;</span=
>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
eft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div class=3D"h5=
"><br><br>On Thursday, February 15, 2018 at 5:54:14 PM UTC-5, Florian Lemai=
tre wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0=
..8ex;border-left:1px #ccc solid;padding-left:1ex">
 =20
   =20
 =20
  <div text=3D"#000000" bgcolor=3D"#FFFFFF">
    On 15/02/2018 20:39, Nicol Bolas wrote:<br>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">On Thursday, February 15, 2018 at 11:33:26 AM
        UTC-5, <a>floria...@gmail.com</a> wrote:
        <blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex">
          <div dir=3D"ltr">Le jeudi 15 f=C3=A9vrier 2018 17:19:29 UTC+1, Ni=
col
            Bolas a =C3=A9crit=C2=A0:
            <blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left=
:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div dir=3D"ltr">On Thursday, February 15, 2018 at 11:06:10
                AM UTC-5, Jake Arkinstall wrote:
                <blockquote class=3D"gmail_quote" style=3D"margin:0;margin-=
left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <div dir=3D"auto">
                    <div>
                      <div>
                        <div class=3D"gmail_quote">On 15 Feb 2018 15:51,
                          &quot;Nicol Bolas&quot; &lt;<a rel=3D"nofollow">j=
mck...@gmail.com</a>&gt;
                          wrote:<br type=3D"attribution">
                          <blockquote style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex">
                            <div dir=3D"ltr">
                              <div>Taking a literal (or possibly
                                constexpr string?)</div>
                            </div>
                          </blockquote>
                        </div>
                      </div>
                    </div>
                    <div dir=3D"auto"><br>
                    </div>
                    <div dir=3D"auto">I was wondering whether it makes
                      sense to even describe these things as literals,
                      given that they aren&#39;t literal and given that the=
y
                      aren&#39;t intended to actually be stored in memory i=
n
                      any way.</div>
                  </div>
                </blockquote>
                <div><br>
                  We still call literals &quot;literals&quot;, even if you =
use
                  them entirely at compile-time via `constexpr` tricks,
                  such that no runtime code ever needs them. Things
                  between quotes are literals.<br>
                  <br>
                </div>
                <blockquote class=3D"gmail_quote" style=3D"margin:0;margin-=
left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <div dir=3D"auto">
                    <div dir=3D"auto">But in terms of constexpr strings, I
                      guess these things themselves can be built up by
                      other methods - I&#39;m not sure if this makes sense
                      in compilation, though; I&#39;m under the impression
                      that the expression itself would likely need to be
                      processed before the constexpr methods themselves
                      could be evaluated (especially given that they
                      could themselves utilise interpolation). I could
                      be wrong.</div>
                    <div dir=3D"auto"><br>
                    </div>
                    <div dir=3D"auto">I think, at this point,
                      interpolation is a bad word - it made sense in the
                      initial form, but now this has generalised we
                      might want a new word for it.</div>
                  </div>
                </blockquote>
                <div><br>
                  I don&#39;t agree. &quot;String interpolation&quot; often=
 carries
                  the connotation that you&#39;re just going to concatenate
                  strings, but it doesn&#39;t <i>have</i> to. C++ sometimes
                  defines concepts with names that are similar to other
                  language features, but in a more open and freeform
                  way. Lambdas for example don&#39;t have lexical scoping i=
n
                  C++ unless you explicitly ask for them, whereas most
                  languages give it to you as a matter of course.<br>
                  <br>
                </div>
                <blockquote class=3D"gmail_quote" style=3D"margin:0;margin-=
left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <div dir=3D"auto">
                    <div dir=3D"auto">
                      <div>
                        <div class=3D"gmail_quote">
                          <blockquote style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex">
                            <div dir=3D"ltr">
                              <div>(or possibly arbitrary expressions?)</di=
v>
                            </div>
                          </blockquote>
                        </div>
                      </div>
                    </div>
                    <div dir=3D"auto"><br>
                    </div>
                    <div dir=3D"auto">This wouldn&#39;t be so much of a
                      problem, because those expressions (other than
                      their declarations) don&#39;t need to be completely
                      understood when the [insert better name for
                      interpolation] is performed - just the resulting
                      type is needed.</div>
                  </div>
                </blockquote>
                <div><br>
                  The issue with &quot;arbitrary expression&quot; is that y=
ou&#39;re
                  now requiring the compiler to <i>invoke the compiler</i>.
                  It&#39;s easy for the compiler to take a compile-time
                  string and find a variable in scope that matches it.
                  It&#39;s much harder (presumably) for the compiler to tak=
e
                  a compile-time string and invoke the compiler on it,
                  within the current scope as if it had been written
                  text.<br>
                  <br>
                  I&#39;m not saying its impossible; I don&#39;t know much =
about
                  compiler architecture. But I can&#39;t imagine it&#39;s a=
s
                  easy as just finding a variable with that name.<br>
                  <br>
                  Not only that, once you get into wanting `constexpr`
                  strings that can be interpolated, you get into lots of
                  issues. Do you really want a feature where you&#39;re abl=
e
                  to synthesize arbitrary expressions and have someone
                  insinuate them into their code at compile time?<br>
                  <br>
                  Or... maybe you do?<br>
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>From what I know about compilation and formal languages
              in general, it shouldn&#39;t be very hard for a compiler to
              deal with expressions within `F&quot;{}&quot;`.</div>
            <div>The compiler already do that kind of stuff with
              parentheses. Compilers are by nature recursive.</div>
          </div>
        </blockquote>
        <div><br>
          You don&#39;t seem to be fully understanding what we&#39;re talki=
ng
          about. This isn&#39;t standard recursive-descent recursion. This
          is &quot;execute some constexpr code and then run the compiler on
          part of its string results.&quot; Those &quot;results&quot; might=
 include
          things like <i>macros</i>, and macro expansion is supposed to
          have happened long before executing constexpr functions.<br>
          <br>
          And you can&#39;t just say they&#39;re expressions minus macros. =
Many
          C-standard library facilities are, or might be, macros after
          all. Is it legal to do `F&quot;{sin(foo)}&quot;`? If string
          interpolation is supposed to allow arbitrary expressions, it
          would be odd indeed if it were not. What about invoking
          `offsetof` or similar C-isms?<br>
          <br>
          If we&#39;re only going to allow string interpolation with genuin=
e
          literals, then this isn&#39;t much of a problem. Even the macro
          issue can be sorted out, since the string is right there in
          the text of the source code.<br>
          <br>
          But if we want string interpolation to ever be applied to the
          results of compile-time execution, that&#39;s going to be <i>much=
</i>
          more complex if string interpolation can handle arbitrary
          expressions. Whereas if we define it to just be variable
          identifiers, extending such interpolation to constexpr strings
          would be much more reasonable.<br>
          <br>
          I would say that any proposal should be focused on the minimum
          featureset. It should naturally include expanding into
          arbitrary expressions and constexpr strings as future
          directions things could take, but I wouldn&#39;t push for them in
          the short term. Sort of like how `constexpr` functions in
          C++11 were really limited, which C++14 greatly expanded.<br>
          <br>
        </div>
        <blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex">
          <div dir=3D"ltr">
            <div>The only thing I don&#39;t know is if the compiler deals
              with string literals as a single token or not. If they do,
              string literal parser will have to be modified quite a
              lot, even with the &quot;identifier-only&quot; variant.<br>
            </div>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
    <div>First thing first, currently the C++ is oblivious to the
      preprocessor, and this will probably not change in the forseeable
      future (note that the preprocessor is somehow aware of C++:
      __cplusplus macro, #include, __has_cpp_attribute...).</div>
    <div>But as far as the compiler is concerned, these are two distinct
      steps that are processed one after the other, without going back.</di=
v>
    <div><br>
    </div>
    <div>Maybe you want to change that, but I think you were mentionning
      macros taking effect within F&quot;{}&quot;.</div></div></blockquote>=
</div></div><div><br>No, I&#39;m mentioning macros taking effect within <i>=
string interpolation</i>.<br><br>We&#39;re talking about the intersection o=
f two things, both of which are still in question:<br><br>1) Arbitrary expr=
essions in interpolation operations.<br>2) The use of constexpr strings as =
the <i>source</i> for interpolation operations; as the string to be interpo=
lated. That is:<br><br><div style=3D"background-color:rgb(250,250,250);bord=
er-color:rgb(187,187,187);border-style:solid;border-width:1px" class=3D"m_-=
2383486546040809004prettyprint"><code class=3D"m_-2383486546040809004pretty=
print"><div class=3D"m_-2383486546040809004subprettyprint"><span style=3D"c=
olor:#008" class=3D"m_-2383486546040809004styled-by-prettify">constexpr</sp=
an><span style=3D"color:#000" class=3D"m_-2383486546040809004styled-by-pret=
tify"> constexpr_string</span><span style=3D"color:#080" class=3D"m_-238348=
6546040809004styled-by-prettify">&lt;char&gt;</span><span style=3D"color:#0=
00" class=3D"m_-2383486546040809004styled-by-prettify"> my_func</span><span=
 style=3D"color:#660" class=3D"m_-2383486546040809004styled-by-prettify">()=
</span><span style=3D"color:#000" class=3D"m_-2383486546040809004styled-by-=
prettify"><br></span><span style=3D"color:#660" class=3D"m_-238348654604080=
9004styled-by-prettify">{</span><span style=3D"color:#000" class=3D"m_-2383=
486546040809004styled-by-prettify"><br>=C2=A0 constexpr_string</span><span =
style=3D"color:#080" class=3D"m_-2383486546040809004styled-by-prettify">&lt=
;char&gt;</span><span style=3D"color:#000" class=3D"m_-2383486546040809004s=
tyled-by-prettify"> a </span><span style=3D"color:#660" class=3D"m_-2383486=
546040809004styled-by-prettify">=3D</span><span style=3D"color:#000" class=
=3D"m_-2383486546040809004styled-by-prettify"> </span><span style=3D"color:=
#080" class=3D"m_-2383486546040809004styled-by-prettify">&quot;here&#39;s a=
 string {sin(5)}&quot;</span><span style=3D"color:#660" class=3D"m_-2383486=
546040809004styled-by-prettify">;</span><span style=3D"color:#000" class=3D=
"m_-2383486546040809004styled-by-prettify"> </span><span style=3D"color:#80=
0" class=3D"m_-2383486546040809004styled-by-prettify">//Note: not doing int=
erpolation.</span><span style=3D"color:#000" class=3D"m_-238348654604080900=
4styled-by-prettify"><br>=C2=A0 constexpr_string</span><span style=3D"color=
:#080" class=3D"m_-2383486546040809004styled-by-prettify">&lt;char&gt;</spa=
n><span style=3D"color:#000" class=3D"m_-2383486546040809004styled-by-prett=
ify"> b </span><span style=3D"color:#660" class=3D"m_-2383486546040809004st=
yled-by-prettify">=3D</span><span style=3D"color:#000" class=3D"m_-23834865=
46040809004styled-by-prettify"> </span><span style=3D"color:#080" class=3D"=
m_-2383486546040809004styled-by-prettify">&quot; more {foo} string&quot;</s=
pan><span style=3D"color:#660" class=3D"m_-2383486546040809004styled-by-pre=
ttify">;</span><span style=3D"color:#000" class=3D"m_-2383486546040809004st=
yled-by-prettify"> </span><span style=3D"color:#800" class=3D"m_-2383486546=
040809004styled-by-prettify">//Still not interpolating.</span><span style=
=3D"color:#000" class=3D"m_-2383486546040809004styled-by-prettify"><br>=C2=
=A0 </span><span style=3D"color:#008" class=3D"m_-2383486546040809004styled=
-by-prettify">return</span><span style=3D"color:#000" class=3D"m_-238348654=
6040809004styled-by-prettify"> a </span><span style=3D"color:#660" class=3D=
"m_-2383486546040809004styled-by-prettify">+</span><span style=3D"color:#00=
0" class=3D"m_-2383486546040809004styled-by-prettify"> b</span><span style=
=3D"color:#660" class=3D"m_-2383486546040809004styled-by-prettify">;</span>=
<span style=3D"color:#000" class=3D"m_-2383486546040809004styled-by-prettif=
y"><br></span><span style=3D"color:#660" class=3D"m_-2383486546040809004sty=
led-by-prettify">}</span><span style=3D"color:#000" class=3D"m_-23834865460=
40809004styled-by-prettify"><br><br></span><span style=3D"color:#008" class=
=3D"m_-2383486546040809004styled-by-prettify">auto</span><span style=3D"col=
or:#000" class=3D"m_-2383486546040809004styled-by-prettify"> str </span><sp=
an style=3D"color:#660" class=3D"m_-2383486546040809004styled-by-prettify">=
=3D</span><span style=3D"color:#000" class=3D"m_-2383486546040809004styled-=
by-prettify"> std</span><span style=3D"color:#660" class=3D"m_-238348654604=
0809004styled-by-prettify">::</span><span style=3D"color:#000" class=3D"m_-=
2383486546040809004styled-by-prettify">concat</span><span style=3D"color:#6=
60" class=3D"m_-2383486546040809004styled-by-prettify">(&lt;</span><span st=
yle=3D"color:#000" class=3D"m_-2383486546040809004styled-by-prettify">inter=
polation syntax</span><span style=3D"color:#660" class=3D"m_-23834865460408=
09004styled-by-prettify">&gt;</span><span style=3D"color:#000" class=3D"m_-=
2383486546040809004styled-by-prettify"> my_func</span><span style=3D"color:=
#660" class=3D"m_-2383486546040809004styled-by-prettify">());</span><span s=
tyle=3D"color:#000" class=3D"m_-2383486546040809004styled-by-prettify"><br>=
<br></span><span style=3D"color:#800" class=3D"m_-2383486546040809004styled=
-by-prettify">//The above is equivalent to:</span><span style=3D"color:#000=
" class=3D"m_-2383486546040809004styled-by-prettify"><br><br></span><span s=
tyle=3D"color:#008" class=3D"m_-2383486546040809004styled-by-prettify">auto=
</span><span style=3D"color:#000" class=3D"m_-2383486546040809004styled-by-=
prettify"> str </span><span style=3D"color:#660" class=3D"m_-23834865460408=
09004styled-by-prettify">=3D</span><span style=3D"color:#000" class=3D"m_-2=
383486546040809004styled-by-prettify"> std</span><span style=3D"color:#660"=
 class=3D"m_-2383486546040809004styled-by-prettify">::</span><span style=3D=
"color:#000" class=3D"m_-2383486546040809004styled-by-prettify">concat</spa=
n><span style=3D"color:#660" class=3D"m_-2383486546040809004styled-by-prett=
ify">(</span><span style=3D"color:#080" class=3D"m_-2383486546040809004styl=
ed-by-prettify">&quot;here&#39;s a string&quot;</span><span style=3D"color:=
#660" class=3D"m_-2383486546040809004styled-by-prettify">,</span><span styl=
e=3D"color:#000" class=3D"m_-2383486546040809004styled-by-prettify"> sin</s=
pan><span style=3D"color:#660" class=3D"m_-2383486546040809004styled-by-pre=
ttify">(</span><span style=3D"color:#066" class=3D"m_-2383486546040809004st=
yled-by-prettify">5</span><span style=3D"color:#660" class=3D"m_-2383486546=
040809004styled-by-prettify">),</span><span style=3D"color:#000" class=3D"m=
_-2383486546040809004styled-by-prettify"> </span><span style=3D"color:#080"=
 class=3D"m_-2383486546040809004styled-by-prettify">&quot; more &quot;</spa=
n><span style=3D"color:#660" class=3D"m_-2383486546040809004styled-by-prett=
ify">,</span><span style=3D"color:#000" class=3D"m_-2383486546040809004styl=
ed-by-prettify"> foo</span><span style=3D"color:#660" class=3D"m_-238348654=
6040809004styled-by-prettify">,</span><span style=3D"color:#000" class=3D"m=
_-2383486546040809004styled-by-prettify"> </span><span style=3D"color:#080"=
 class=3D"m_-2383486546040809004styled-by-prettify">&quot; string&quot;</sp=
an><span style=3D"color:#660" class=3D"m_-2383486546040809004styled-by-pret=
tify">);</span><span style=3D"color:#000" class=3D"m_-2383486546040809004st=
yled-by-prettify"><br></span></div></code></div><br>It&#39;s the <i>combina=
tion</i> of these two things that doesn&#39;t work. By the time the compile=
r gets around to actually processing the `my_func` call, macro expansion ha=
s come and gone. So how does `sin(5)` get expanded properly?<br><br>And I k=
now you&#39;re thinking that constexpr strings don&#39;t exist, that they&#=
39;re not even really possible. Yet; the committee is working on expansions=
 to constexpr that allow memory allocation. Once that happens, we will have=
 constexpr strings. And once we do, there&#39;s no reason you should preven=
t constexpr strings from being the source of interpolation operations.<br><=
br>Well, no reason unless you sandbag interpolation by requiring it to allo=
w arbitrary expressions. My feeling is that you have to pick one or the oth=
er: you either allow=20
arbitrary expressions or you allow constexpr string interpolation. And=20
if we can only have one, I&#39;d much rather have the latter.<br><br>I want=
 constexpr strings to be equivalent to literals as much as possible.<br></d=
iv><br></div></blockquote></div><div>I get your problem now.<br></div><div>=
Just to simplify my explanations, let&#39;s assume that string interpolatio=
n is done via a prefix operator called $.</div><div><br></div><div>You
 want to be able to call $ on any constexpr string, and also it would be
 nice to also have expressions in the interpolation pattern. But as you=20
said, having both would trigger the compiler on compiler output, and=20
this would be difficult to handle.</div><div>I now agree with you on the co=
mplexity of having both.</div><div><br></div><div>What you&#39;re describin=
g here looks like some compile-time &quot;eval&quot;.</div><div><div style=
=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-=
style:solid;border-width:1px" class=3D"gmail-prettyprint"><code class=3D"gm=
ail-prettyprint"><div class=3D"gmail-subprettyprint"><span style=3D"color:r=
gb(0,0,136)" class=3D"gmail-styled-by-prettify">constexpr</span><span style=
=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-prettify"> </span><span styl=
e=3D"color:rgb(0,0,136)" class=3D"gmail-styled-by-prettify">auto</span><spa=
n style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-prettify"> call_foo <=
/span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-styled-by-prettif=
y">=3D</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-pret=
tify"> </span><span style=3D"color:rgb(0,136,0)" class=3D"gmail-styled-by-p=
rettify">&quot;{foo()}&quot;</span><span style=3D"color:rgb(102,102,0)" cla=
ss=3D"gmail-styled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" cl=
ass=3D"gmail-styled-by-prettify"><br><br></span><span style=3D"color:rgb(13=
6,0,0)" class=3D"gmail-styled-by-prettify">// eval:</span><span style=3D"co=
lor:rgb(0,0,0)" class=3D"gmail-styled-by-prettify"><br>$ call_foo</span><sp=
an style=3D"color:rgb(102,102,0)" class=3D"gmail-styled-by-prettify">;</spa=
n><span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-prettify"><br><=
/span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-styled-by-prettify"=
>// translated to:</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-st=
yled-by-prettify"><br>foo</span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-styled-by-prettify">();</span><span style=3D"color:rgb(0,0,0)" cl=
ass=3D"gmail-styled-by-prettify"><br></span></div></code></div><br>This loo=
ks nasty.<br></div><div>It would be possible to leak local variables:</div>=
<div><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,1=
87,187);border-style:solid;border-width:1px" class=3D"gmail-prettyprint"><c=
ode class=3D"gmail-prettyprint"><div class=3D"gmail-subprettyprint"><span s=
tyle=3D"color:rgb(0,0,136)" class=3D"gmail-styled-by-prettify">int</span><s=
pan style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-prettify"> super_pr=
ivate_copy</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-styled=
-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-style=
d-by-prettify"><br><br></span><span style=3D"color:rgb(0,0,136)" class=3D"g=
mail-styled-by-prettify">auto</span><span style=3D"color:rgb(0,0,0)" class=
=3D"gmail-styled-by-prettify"> foo</span><span style=3D"color:rgb(102,102,0=
)" class=3D"gmail-styled-by-prettify">(</span><span style=3D"color:rgb(136,=
0,0)" class=3D"gmail-styled-by-prettify">/*whatever equivalent to string li=
teral*/</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-pre=
ttify"> s</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-styled-=
by-prettify">)</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled=
-by-prettify"> </span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-s=
tyled-by-prettify">{</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-=
styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(0,0,136)" cl=
ass=3D"gmail-styled-by-prettify">int</span><span style=3D"color:rgb(0,0,0)"=
 class=3D"gmail-styled-by-prettify"> super_private </span><span style=3D"co=
lor:rgb(102,102,0)" class=3D"gmail-styled-by-prettify">=3D</span><span styl=
e=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-prettify"> </span><span sty=
le=3D"color:rgb(0,102,102)" class=3D"gmail-styled-by-prettify">5</span><spa=
n style=3D"color:rgb(102,102,0)" class=3D"gmail-styled-by-prettify">;</span=
><span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-prettify"><br>=
=C2=A0 </span><span style=3D"color:rgb(0,0,136)" class=3D"gmail-styled-by-p=
rettify">return</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-style=
d-by-prettify"> std</span><span style=3D"color:rgb(102,102,0)" class=3D"gma=
il-styled-by-prettify">::</span><span style=3D"color:rgb(0,0,0)" class=3D"g=
mail-styled-by-prettify">concat</span><span style=3D"color:rgb(102,102,0)" =
class=3D"gmail-styled-by-prettify">(</span><span style=3D"color:rgb(0,0,0)"=
 class=3D"gmail-styled-by-prettify">$ s</span><span style=3D"color:rgb(102,=
102,0)" class=3D"gmail-styled-by-prettify">);</span><span style=3D"color:rg=
b(0,0,0)" class=3D"gmail-styled-by-prettify"><br></span><span style=3D"colo=
r:rgb(102,102,0)" class=3D"gmail-styled-by-prettify">}</span><span style=3D=
"color:rgb(0,0,0)" class=3D"gmail-styled-by-prettify"><br><br></span><span =
style=3D"color:rgb(0,0,136)" class=3D"gmail-styled-by-prettify">void</span>=
<span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-prettify"> bar</s=
pan><span style=3D"color:rgb(102,102,0)" class=3D"gmail-styled-by-prettify"=
>()</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-prettif=
y"> </span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-styled-by-pr=
ettify">{</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-p=
rettify"><br>=C2=A0 foo</span><span style=3D"color:rgb(102,102,0)" class=3D=
"gmail-styled-by-prettify">(</span><span style=3D"color:rgb(0,136,0)" class=
=3D"gmail-styled-by-prettify">&quot;{super_private_copy =3D super_private}&=
quot;</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-styled-by-p=
rettify">);</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by=
-prettify"><br>=C2=A0 std</span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-styled-by-prettify">::</span><span style=3D"color:rgb(0,0,0)" cla=
ss=3D"gmail-styled-by-prettify">cout </span><span style=3D"color:rgb(102,10=
2,0)" class=3D"gmail-styled-by-prettify">&lt;&lt;</span><span style=3D"colo=
r:rgb(0,0,0)" class=3D"gmail-styled-by-prettify"> </span><span style=3D"col=
or:rgb(0,136,0)" class=3D"gmail-styled-by-prettify">&quot;super_private: &q=
uot;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-pretti=
fy"> </span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-styled-by-p=
rettify">&lt;&lt;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-sty=
led-by-prettify"> super_private_copy </span><span style=3D"color:rgb(102,10=
2,0)" class=3D"gmail-styled-by-prettify">&lt;&lt;</span><span style=3D"colo=
r:rgb(0,0,0)" class=3D"gmail-styled-by-prettify"> std</span><span style=3D"=
color:rgb(102,102,0)" class=3D"gmail-styled-by-prettify">::</span><span sty=
le=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-prettify">endl</span><span=
 style=3D"color:rgb(102,102,0)" class=3D"gmail-styled-by-prettify">;</span>=
<span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-prettify"><br></s=
pan><span style=3D"color:rgb(102,102,0)" class=3D"gmail-styled-by-prettify"=
>}</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-by-prettify=
"><br></span></div></code></div></div><div><br>This
 little fictive example shows how this would be possible with those=20
assumptions. And this intrinsically bad, independently to the=20
implementation complexity.</div><div>The outer world should not affect a
 private scope without its consent. (so this does not apply if some=20
global is used within the private scope: in that case, the access to the
 global is consented by the private scope)</div><div><br></div><div><br></d=
iv><div>So definitely, having both string interpolation pattern from conste=
xpr strings <b>and</b> expressions can be interpolated is conceptually bad.=
</div><div><br></div><div>So let&#39;s consider only string interpolation p=
attern from constexpr strings.</div><div>This also breaks private scope (mo=
re tricky though).</div><div><div style=3D"background-color:rgb(250,250,250=
);border-color:rgb(187,187,187);border-style:solid;border-width:1px" class=
=3D"gmail-prettyprint"><code class=3D"gmail-prettyprint"><div class=3D"gmai=
l-subprettyprint"><span style=3D"color:rgb(0,0,136)" class=3D"gmail-styled-=
by-prettify">// intended to use access1, access2, access3 or access4 as pat=
tern<br>auto</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-styled-b=
y-prettify"> foo</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-=
styled-by-prettify">(</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail=
-styled-by-prettify"><code class=3D"gmail-prettyprint"><span style=3D"color=
:rgb(136,0,0)" class=3D"gmail-styled-by-prettify">/*whatever equivalent to =
string literal*/</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-styl=
ed-by-prettify"> s) {<br>=C2=A0 int super_secret =3D 5;<br>=C2=A0 int acces=
s1 =3D 1;<br>=C2=A0 int access2 =3D 2;<br>=C2=A0 int access3 =3D 3;<br>=C2=
=A0 int access4 =3D 4;<br>=C2=A0 return std::make_tuple($ s);<br>}<br><br>v=
oid bar() {<br>=C2=A0 auto super_secret =3D std::get&lt;0&gt;(foo(&quot;{su=
per_secret}&quot;));<br>=C2=A0 std::cout &lt;&lt; &quot;super_secret: &quot=
; &lt;&lt; super_secret &lt;&lt; std::endl;<br>}<br></span><span style=3D"c=
olor:rgb(102,102,0)" class=3D"gmail-styled-by-prettify"></span></code></spa=
n></div></code></div></div><div><br>Yes, this example is more convoluted, b=
ut it still shows what is possible to do.</div><div><br></div><div>Another =
thing that could be a problem: what happens if a variable is not declared? =
It probably should not compile.</div><div>But then we could have pretty com=
plex and hard to debug code:</div><div><div style=3D"background-color:rgb(2=
50,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1=
px" class=3D"gmail-prettyprint"><code class=3D"gmail-prettyprint"><div clas=
s=3D"gmail-subprettyprint"><span style=3D"color:rgb(102,0,102)" class=3D"gm=
ail-styled-by-prettify">constexpr auto foo</span><span style=3D"color:rgb(1=
02,102,0)" class=3D"gmail-styled-by-prettify"></span>(int i); // returns a =
&quot;string literal&quot;-like that has the form &quot;{foo###}&quot; wher=
e ### is the i-th prime number<br><br>void bar() {<br>=C2=A0 int foo3 =3D 0=
;<br>=C2=A0 do_whatever($ foo(2));<br>} // This compiles<br><br>void baz() =
{<br>=C2=A0 int foo4 =3D 0;<br>=C2=A0 do_whatever($ foo(2));<br>} // This d=
oesn&#39;t compile (obviously)<br></div></code></div><br>Why
 is it different than just access a global variable with the right name?
 There is no way to know what variables are needed in order to compile=20
other than trying to compile the program.</div><div>The identifier foo3 is =
never defined, and never appears in the code (except within your function).=
</div><div>Moreover,
 your local scope now is entangled with the value returned by foo().=20
(this kind of breaks encapsulation of the local scope)</div><div><br></div>=
<div>Maybe
 your fine with this one, but I&#39;m not. That&#39;s why I think string=20
interpolation should not apply to constexpr strings (at least, not the=20
interpolation pattern).</div><div><br></div><div>Don&#39;t get me wrong: I=
=20
am perfectly fine to standardize only string interpolation on actual=20
string literal with only identifiers in patterns, and see later how to=20
improve it.</div><div>But as far as I&#39;m concerned, I think interpolatin=
g
 constexpr patterns is a bad idea and I would much prefer arbitrary=20
expressions to be interpolated.<br></div><div><br></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/CANaF6iikVH-jjGFxx2whvec%3DwcRPeXDwTZ=
SevxD9anWhY9zh0g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANaF6iikVH-jjG=
Fxx2whvec%3DwcRPeXDwTZSevxD9anWhY9zh0g%40mail.gmail.com</a>.<br />

--001a114bb2645977e5056550d40c--

.
