220 27637 <7938962d-5e90-4e0f-b3f2-4f979d314a70@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: inkwizytoryankes@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: this in non-member functions
Date: Fri, 5 Aug 2016 11:54:07 -0700 (PDT)
Lines: 196
Approved: news@gmane.org
Message-ID: <7938962d-5e90-4e0f-b3f2-4f979d314a70@isocpp.org>
References: <CAA7YVg3ObHqk-rfGRqgCqw3D-=u2pOwz=p8NHtC6n9tpBLq-Aw@mail.gmail.com>
 <cf5b6196-63bc-49ff-8a6a-bfdfb8a7ab0e@isocpp.org> <CAA7YVg2BQaVD2MyLyyEWuzWUnqjGrNUUi9eZwy7skjq8=ourvA@mail.gmail.com>
 <2351486.cE391vEbrj@tjmaciei-mobl1> <CACGiwhEAN4R2xE9g84xk6KKDB76+PpLFUt_Af6aKhDpAMf8Lqw@mail.gmail.com>
 <nnv12b$okq$1@blaine.gmane.org> <CAA7YVg3jtYJ8JdLqqvN1eGx0L21Bef2J-atc0_ufUwKxtsiVSQ@mail.gmail.com>
 <814750ea-1ef8-4792-9b50-aec0bae4d841@isocpp.org>
 <CAA7YVg3HCFXrd-f+Duq2nyM4oHkOwWPuXFp4dZUDUB3ocor3gQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2239_1579967262.1470423247672"
X-Trace: blaine.gmane.org 1470423267 4439 195.159.176.226 (5 Aug 2016 18:54:27 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 5 Aug 2016 18:54:27 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDDLTAGNTIBBBUGBSO6QKGQEZ5J5D3Y@isocpp.org Fri Aug 05 20:54:23 2016
Return-path: <std-proposals+bncBDDLTAGNTIBBBUGBSO6QKGQEZ5J5D3Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f70.google.com ([209.85.213.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDDLTAGNTIBBBUGBSO6QKGQEZ5J5D3Y@isocpp.org>)
	id 1bVkG2-0007AA-Fi
	for gclcip-std-proposals@m.gmane.org; Fri, 05 Aug 2016 20:54:10 +0200
Original-Received: by mail-vk0-f70.google.com with SMTP id w127sf495438425vkh.1
        for <gclcip-std-proposals@m.gmane.org>; Fri, 05 Aug 2016 11:54:10 -0700 (PDT)
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
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=aZLwG9zsSRXQE6uF9W1mXchOyfmmjNBXkhb9xxrKLSA=;
        b=ShAbbx2EU/yzAyZmny406iyMOEQWWDqlwBPwqgEdtkGQKvL+sl/pFkGHDlfwD1gSZz
         BJ5yrP8qBnC0NaHR4yBwy1DvkcKuyeQDrbsclpF05WYDoXBTWfN4AsW6c71OOrWRjS4k
         IUKEIbZERpdQzlXzFZlhOas1e6mIhsZwxXeBK3gC5/YyQFr5YIXznJ4DTnZYzy2cIxlW
         QYEboH2oSH2N/u9n3TYZ3uUy6GPIh5MseNZaF6TH1oBSonvbF66rUtxCQwLE67ijxcny
         ruHq4sYl+tTuX4VsQafcBGUTFqsUp7JXOAUot+tFvWkNlFUZoh1XnmVLKBUqjLXuf6CR
         nWSA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=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=aZLwG9zsSRXQE6uF9W1mXchOyfmmjNBXkhb9xxrKLSA=;
        b=zsCLmPktxUb2MPBK5fyTIjwxs/jqNBBt3GYvIBC5tA9+Uuxoe4HescImq7lB1RZKr/
         E+VGOS81BwuG8sWkbiOgkrBVWTwyCtW3L7tnAGi39y1hV3nOeIs9e9VBv/9E+MJDWpCx
         +9D0I9JgCnJD6FiWF9/fKW5telro8YyiYlb2/FVT5Xam/zlOLBstUxKkHrhkHnAfDiQy
         EK7aJjyf2wMYVhJIAbNjlQbXHvdby9xhBK5PIZ4bd8HcZcXjvaPLBgOk91j/qKN4u03c
         wiw19xl46qxn7mZUecvtuoQGLLEja1LxgLBvKM7NTl4SCNZtuk+McDcD0ICGHhTqq6uy
         rdLA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        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=aZLwG9zsSRXQE6uF9W1mXchOyfmmjNBXkhb9xxrKLSA=;
        b=TNcx8d1pq3BJhIcXOKGpLbKCcwuEvb1nxi8IdI3TnnGib8097ShcayKNfHX7DHgP2F
         SFuf5x0jcmTd0vn239d5+BKqgUzKfphcdrBgpV87maZEGiuXgfR8UDYxac5VLTV6eUk5
         mHEZxLPEj/lpycWdabsXJx9fvn/5lP4aMPuXcOXrCGspxGeA6SvEzVefig7cvAZwuq1A
         qDNqe+54gK3TV9MhbSWBPaT/TxlNviVOkBctXrukcS1MIKi2bqLppdULA7hTvuSUfPSm
         k2TE28eScl9uHGmdbXk8Q82lic6wm7ZfqacTtqUiuGBQgr+giX5Z7ZxQiylhwETiJpCX
         qtXw==
X-Gm-Message-State: AEkoout31510S0MRXL3PiEb5vHrkDfdJ6Yr/nN62NAmPdgDx8Q37pGtc0pyB0LReoCeXZQ==
X-Received: by 10.13.217.135 with SMTP id b129mr69204334ywe.13.1470423250418;
        Fri, 05 Aug 2016 11:54:10 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.18.12 with SMTP id a12ls2632711ioj.18.gmail; Fri, 05 Aug
 2016 11:54:08 -0700 (PDT)
X-Received: by 10.36.91.205 with SMTP id g196mr230006itb.0.1470423248704;
        Fri, 05 Aug 2016 11:54:08 -0700 (PDT)
In-Reply-To: <CAA7YVg3HCFXrd-f+Duq2nyM4oHkOwWPuXFp4dZUDUB3ocor3gQ@mail.gmail.com>
X-Original-Sender: inkwizytoryankes@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <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:27637
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/27637>

------=_Part_2239_1579967262.1470423247672
Content-Type: multipart/alternative; 
	boundary="----=_Part_2240_1672624294.1470423247672"

------=_Part_2240_1672624294.1470423247672
Content-Type: text/plain; charset=UTF-8



On Friday, August 5, 2016 at 7:51:37 PM UTC+2, Viacheslav Usov wrote:
>
> On Fri, Aug 5, 2016 at 7:17 PM, <inkwizyt...@gmail.com <javascript:>> 
> wrote:
>
> template<typename T>
>> void f(T* this)
>> {
>>     a = 6;
>> };
>> What meaning have this code? `a` is member or global value?
>> Because member `a` is dependent name compiler need always ignore it and 
>> go for global with same name.
>> This made this proposition unusable in template contexts.
>>
>
> When this is instantiated for a particular type T, then, if there is a 
> member 'a' in that type, it will mean this->a = 6; if there is no such 
> member, it will refer to 'a' from an outer scope. Note that at this point I 
> no longer propose that 'this' could be declared as a regular variable. 
> Instead, I propose the following form:
>
> using this = expression;
>
> Cheers,
> V.
>

But then this will be first time when C++ template quietly change syntax of 
code when you instantiating different templates, consider this case:

class a{};
struct t1
{
  void f()
  {
    a* test;
    ++test;
  }
};
struct t2
{
  int a;
  int test;
  void f()
  {
    a* test;
    ++test;
  }
};
`t1::f` and `t2::f` look similar but work completely different. How 
compilers will handle cases when every symbol in function can be member 
variable?
JavaScript had same problems with `with` and solution was to ban it: 
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with


-- 
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/7938962d-5e90-4e0f-b3f2-4f979d314a70%40isocpp.org.

------=_Part_2240_1672624294.1470423247672
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Friday, August 5, 2016 at 7:51:37 PM UTC+2, Via=
cheslav Usov wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D=
"ltr"><div><div class=3D"gmail_quote">On Fri, Aug 5, 2016 at 7:17 PM,  <spa=
n dir=3D"ltr">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-=
mailto=3D"m3_X1SPyBwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;ja=
vascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;r=
eturn true;">inkwizyt...@gmail.com</a>&gt;</span> wrote:</div><div class=3D=
"gmail_quote"><br><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=
 style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);b=
order-style:solid;border-width:1px;word-wrap:break-word"><code><div><span s=
tyle=3D"color:#008">template</span><span style=3D"color:#660">&lt;</span><s=
pan style=3D"color:#008">typename</span><span style=3D"color:#000"> T</span=
><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></spa=
n><span style=3D"color:#008">void</span><span style=3D"color:#000"> f</span=
><span style=3D"color:#660">(</span><span style=3D"color:#000">T</span><spa=
n style=3D"color:#660">*</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">this</span><span style=3D"color:#660">)</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span style=
=3D"color:#000"><br>=C2=A0 =C2=A0 a </span><span style=3D"color:#660">=3D</=
span><span style=3D"color:#000"> </span><span style=3D"color:#066">6</span>=
<span style=3D"color:#660">;</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">};</span><span style=3D"color:#000"><br></span></d=
iv></code></div>What meaning have this code? `a` is member or global value?=
<br>Because member `a` is dependent name compiler need always ignore it and=
 go for global with same name.<br>This made this proposition unusable in te=
mplate contexts.</div></div></blockquote><div><br></div><div>When this is i=
nstantiated for a particular type T, then, if there is a member &#39;a&#39;=
 in that type, it will mean this-&gt;a =3D 6; if there is no such member, i=
t will refer to &#39;a&#39; from an outer scope. Note that at this point I =
no longer propose that &#39;this&#39; could be declared as a regular variab=
le. Instead, I propose the following form:</div><div><br></div><div>using t=
his =3D expression;<br></div><div><br></div><div>Cheers,</div><div>V.</div>=
</div></div></div></blockquote><div><br>But then this will be first time wh=
en C++ template quietly change syntax of code when you instantiating differ=
ent templates, consider this case:<br><div class=3D"prettyprint" style=3D"b=
ackground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); bord=
er-style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"=
prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">class</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{};</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><code class=3D"prettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"></span></code><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">t1<br></span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">voi=
d</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> f</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 a</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> test</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">++</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">test</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> t2<br></span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> test</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 a</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> test</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">++</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">test</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">};</span></div></code></div>`t1::f` and `t2::f` look similar but =
work completely different. How compilers will handle cases when every symbo=
l in function can be member variable?<br>JavaScript had same problems with =
`with` and solution was to ban it: https://developer.mozilla.org/en-US/docs=
/Web/JavaScript/Reference/Statements/with<br><br><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/7938962d-5e90-4e0f-b3f2-4f979d314a70%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7938962d-5e90-4e0f-b3f2-4f979d314a70=
%40isocpp.org</a>.<br />

------=_Part_2240_1672624294.1470423247672--

------=_Part_2239_1579967262.1470423247672--

.
