220 16616 <a468b6c7-d1c3-4063-b7d9-e4a678c2af79@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Zijie He <hzj_jie@hotmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Comment on N4165, N4174
Date: Mon, 2 Mar 2015 16:07:46 -0800 (PST)
Lines: 420
Approved: news@gmane.org
Message-ID: <a468b6c7-d1c3-4063-b7d9-e4a678c2af79@isocpp.org>
References: <CAHka5EX63s+CHz3kR_rVShSzFq98kyynknsg1T3T=CSYtVm8ag@mail.gmail.com>
 <8c9d5f60-8c76-4763-9da6-c159db1f3d80@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_3693_576688624.1425341266670"
X-Trace: ger.gmane.org 1425341286 4430 80.91.229.3 (3 Mar 2015 00:08:06 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 3 Mar 2015 00:08:06 +0000 (UTC)
Cc: gmisocpp@gmail.com, bs@ms.com, hsutter@microsoft.com
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD6IXSMN7QKRBU7W2OTQKGQEAJ7PE3Y@isocpp.org Tue Mar 03 01:07:52 2015
Return-path: <std-proposals+bncBD6IXSMN7QKRBU7W2OTQKGQEAJ7PE3Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f70.google.com ([209.85.218.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD6IXSMN7QKRBU7W2OTQKGQEAJ7PE3Y@isocpp.org>)
	id 1YSaNK-0001ja-8y
	for gclcip-std-proposals@m.gmane.org; Tue, 03 Mar 2015 01:07:50 +0100
Original-Received: by mail-oi0-f70.google.com with SMTP id u20sf236699295oif.1
        for <gclcip-std-proposals@m.gmane.org>; Mon, 02 Mar 2015 16:07:49 -0800 (PST)
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:cc:message-id:in-reply-to
         :references:subject:mime-version:content-type:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=Rwl+DJ6ZKrWD4ZzmQ70McBuW7BELvkKbh6WSoSZbjdA=;
        b=fsfqwkBdwWb0bgF7YWjLTT8B0MeHyc1lYrPzmdQAJ0D9S1+PgIgaEk+fmTSM+I8m67
         UQmKyE2CN5k8weQ6VqlCVHlyqP7FLyRpuDEtQsdHhsUu1UWmX1HSRIgwt06/kUSl+kNz
         CHt/Atlxv21hJImr465FiwCsYQBiRV5MVQiSYdR1ELPUHpsrxL1kMyvimvxUMkEe2X37
         0F4lgRuIOGuIHra+jaHEjJgIt6tybb7G9mgA6f38U6m3KoC4H7F3g8YpNnvQ7NYlPt/9
         HM9QWw7iDN+6geNn53lBd+vb1siB4COjPY53jA9Eg7VEDVjeOuwHfho/zDj7gKzL2bts
         lT5g==
X-Gm-Message-State: ALoCoQkgcHqyRrJZx4LzTzkspTOy2siktlNraAlGQaFk3diVS/4jIJtalWsZ391W8Bey1TMzwrte
X-Received: by 10.43.63.196 with SMTP id xf4mr30332074icb.22.1425341269037;
        Mon, 02 Mar 2015 16:07:49 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.27.3 with SMTP id p3ls798782obg.25.gmail; Mon, 02 Mar 2015
 16:07:47 -0800 (PST)
X-Received: by 10.182.4.101 with SMTP id j5mr207297obj.24.1425341267054;
        Mon, 02 Mar 2015 16:07:47 -0800 (PST)
In-Reply-To: <8c9d5f60-8c76-4763-9da6-c159db1f3d80@isocpp.org>
X-Original-Sender: Hzj_jie@hotmail.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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:16616
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/16616>

------=_Part_3693_576688624.1425341266670
Content-Type: multipart/alternative; 
	boundary="----=_Part_3694_812004657.1425341266670"

------=_Part_3694_812004657.1425341266670
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Personally I really like the idea of N4174, though several serious concerns=
,
1. f(x,y) means 1. First try x.f(y) =E2=80=93 does x=E2=80=99s class have a=
 member f? If so=20
try to use it 2. First try f(x,y) =E2=80=93 is there a function f? If so, t=
ry to=20
use it 3. otherwise error
This is totally wrong. We can have both f(x, y) and x.f(y) in the code, but=
=20
this new syntax blocks f(x, y) been called if x.f(y) exists.

2. The doc does not mention the scenario when an inheritance or implicit=20
conversion happened. i.e.

class B { public: void f() { } };
class D : B { };
void f(D&) { }

Which function will be called in the following scenarios?
a. B* i =3D new D(); i->f();
b. D i; i.f();

class B { public: virtual void f() =3D 0 };
class D : B { };
void f(D&) { }

Will the void f(D&) be considered as the override of B::f?

class B { };
class D : B { public: void f() { } };
void f(B&) { }

Which function will be called?
B* i =3D new D(); i->f();

class A { };
class B { public: operator A() { ... }; public: void f() { }; };
void f(A&) { }

Which function will be called when
B i; f(i);

3. c, v, cv, c&, v&, cv&, r-value reference ?
void f(const C&) { }
void f(C&) { }
void f(C) { }
void f(volatile const& C) { }
....

When
C i; i.f();
Which function should be called, should it be consistent with f(i)?

4. Will f(C*) be supported?

class C { };
void f(C*) { }
void f(C&) { }

Which function should be called?
C c; c.f(); (&c)->f();
C* c =3D new C(); c->f(); (*c).f();
It would be really funky, if the behavior of c.f() and (&c)->f() are=20
different.

5. nullptr?

class A { public: void f() { } };
class B { };
void f(B&) { }

Will the following calls crash?
A* a =3D nullptr;
f(a);
B* b =3D nullptr;
b->f();

And, how about
class A { };
void f(A*) { }
A* i =3D nullptr;
i->f();

Let's define all the cases we may have, and make this doc become the=20
standard. So involve the original authors of both 4165 and 4174.


On Tuesday, March 3, 2015 at 5:13:04 AM UTC+8, gmis...@gmail.com wrote:
>
> I'm very keen on Bjarne's variant of the proposal.
> As Walter says, I think it'll be amazingly useful.
>
> I would like to see some more talk explaining what it initially recommend=
=20
> regarding access to private members and the pros/cons of it but I'm keen=
=20
> for this proposal to progress and look out for it's progress in each=20
> mailing. I'm interested in what other people think of the proposal. I'm=
=20
> particular interested to know if any compiler has speculatively implement=
ed=20
> it so I could play with it but that's probably wishful thinking.
>
> On Monday, October 27, 2014 at 9:24:31 PM UTC+13, Ryou Ezoe wrote:
>
>> I have some comments on N4165/N4174.=20
>>
>> 1. weird code=20
>> It's my understanding that under this proposal, following code is=20
>> well-formed.=20
>>
>> 4.0.sqrt() ;=20
>> "hello".puts() ;=20
>>
>> Is this correct?=20
>>
>>
>> If so and If we allow N4165's "Additionally allow =E2=80=9Cthis=E2=80=9D=
 in not only=20
>> the first parameter location",=20
>> It does allow this:=20
>>
>> fp->fputs("hello") ;=20
>>
>> as well as this:=20
>>
>> "hello"->fputs(fp) ;=20
>>
>>
>> 2. Tool support=20
>> The papers wrote about better tool support.=20
>> Although I agree with the idea, there are so many too generic function=
=20
>> templates in the standard library that bloat up the auto completion=20
>> candidates.=20
>> Like move, swap, addressof.=20
>>
>> Without some constrained template features like concept or some hard=20
>> coded/heuristic restriction on tool implementation,=20
>> a set of auto completion name candidates are indeed smaller than free=20
>> functions, but not that small enough.=20
>>
>> Consider FILE from <stdio.h>.=20
>> The paper said it can auto complete fseek.=20
>>
>> FILE * fp ;=20
>> fp->fseek=20
>>
>> It looks nice.=20
>>
>> But, Annex D.5 said C headers are deprecated and we should use C++=20
>> header(<cstdio>) instead.=20
>> So we should write like this:=20
>>
>> std::FILE * fp =3D ... ;=20
>>
>> This add std namespace to fp's associated namespace so all standard=20
>> library names are on the candidate list.=20
>>
>> Suppose we also #included <algorithm> and wrote:=20
>>
>> fp->=20
>>
>> Tool suggest all <algorithm> function templates because fp is a pointer.=
=20
>>
>> fp->for_each=20
>>
>> Even if without ADL, id-expression allows qualified-id so a tool just=20
>> list up all viable functions:=20
>>
>> fp->std::for_each=20
>>
>>
>> This is only considering the standard library, I think users also=20
>> wrote many too generic functions like this.=20
>> Combining those, auto completion candidates will bloat up with=20
>> completely unrelated generic function names user don't expect it to be=
=20
>> suggested.=20
>>
>>
>> I don't think tool support situation will be any better with this=20
>> proposal.=20
>> It may be worse because candidate bloat up also affect existing class=20
>> types and overwhelm the result.=20
>>
>> Very common types(like const char *, long double etc) and class types=20
>> which has user defined conversion to common types now shows all sort=20
>> of common functions as well as user defined literals!=20
>>
>> long double ld ;=20
>> ld.operator "" il() ; // std::complex<long double>=20
>>
>>
>> What do you think?=20
>>
>> --=20
>> Ryou Ezoe=20
>>
>> Occupation: DWANGO Co., Ltd.=20
>>
>> Blog:     http://cpplover.blogspot.com/=20
>> Twitter: https://twitter.com/EzoeRyou=20
>> GitHub: https://github.com/EzoeRyou=20
>>
>

--=20

---=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_3694_812004657.1425341266670
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Personally I really like the idea of N4174, though several=
 serious concerns,<div>1.&nbsp;f(x,y) means 1. First try x.f(y) =E2=80=93 d=
oes x=E2=80=99s class have a member f? If so try to use it 2. First try f(x=
,y) =E2=80=93 is there a function f? If so, try to use it 3. otherwise erro=
r</div><div>This is totally wrong. We can have both f(x, y) and x.f(y) in t=
he code, but this new syntax blocks f(x, y) been called if x.f(y) exists.</=
div><div><br></div><div>2. The doc does not mention the scenario when an in=
heritance or implicit conversion happened. i.e.</div><div><br></div><div>cl=
ass B { public: void f() { } };</div><div>class D : B { };</div><div>void f=
(D&amp;) { }</div><div><br></div><div>Which function will be called in the =
following scenarios?</div><div>a. B* i =3D new D(); i-&gt;f();</div><div>b.=
 D i; i.f();</div><div><br></div><div>class B { public: virtual void f() =
=3D 0 };</div><div>class D : B { };</div><div>void f(D&amp;) { }</div><div>=
<br></div><div>Will the void f(D&amp;) be considered as the override of B::=
f?</div><div><br></div><div>class B { };</div><div>class D : B { public: vo=
id f() { } };</div><div>void f(B&amp;) { }</div><div><br></div><div>Which f=
unction will be called?</div><div>B* i =3D new D(); i-&gt;f();</div><div><b=
r></div><div>class A { };</div><div>class B { public: operator A() { ... };=
 public: void f() { }; };</div><div>void f(A&amp;) { }</div><div><br></div>=
<div>Which function will be called when</div><div>B i; f(i);</div><div><br>=
</div><div>3. c, v, cv, c&amp;, v&amp;, cv&amp;, r-value reference ?</div><=
div>void f(const C&amp;) { }</div><div>void f(C&amp;) { }</div><div>void f(=
C) { }</div><div>void f(volatile const&amp; C) { }</div><div>...</div><div>=
<br></div><div>When</div><div>C i; i.f();</div><div>Which function should b=
e called, should it be consistent with f(i)?</div><div><br></div><div>4. Wi=
ll f(C*) be supported?</div><div><br></div><div>class C { };</div><div>void=
 f(C*) { }</div><div>void f(C&amp;) { }</div><div><br></div><div>Which func=
tion should be called?</div><div>C c; c.f(); (&amp;c)-&gt;f();</div><div>C*=
 c =3D new C(); c-&gt;f(); (*c).f();</div><div>It would be really funky, if=
 the behavior of c.f() and (&amp;c)-&gt;f() are different.</div><div><br></=
div><div>5. nullptr?</div><div><br></div><div>class A { public: void f() { =
} };</div><div>class B { };</div><div>void f(B&amp;) { }</div><div><br></di=
v><div>Will the following calls crash?</div><div>A* a =3D nullptr;</div><di=
v>f(a);</div><div>B* b =3D nullptr;</div><div>b-&gt;f();</div><div><br></di=
v><div>And, how about</div><div>class A { };</div><div>void f(A*) { }</div>=
<div>A* i =3D nullptr;</div><div>i-&gt;f();</div><div><br></div><div>Let's =
define all the cases we may have, and make this doc become the standard. So=
 involve the original authors of both 4165 and 4174.</div><div><br></div><b=
r>On Tuesday, March 3, 2015 at 5:13:04 AM UTC+8, gmis...@gmail.com wrote:<b=
lockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;borde=
r-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>I'm very k=
een on Bjarne's variant of the proposal.</div><div>As Walter says, I think =
it'll be&nbsp;amazingly useful.</div><div><br></div><div>I would like to se=
e some more talk&nbsp;explaining&nbsp;what it&nbsp;initially recommend rega=
rding access to private members and&nbsp;the pros/cons of it&nbsp;but I'm k=
een for this proposal to progress and look out for it's progress in each ma=
iling.&nbsp;I'm&nbsp;interested in what other people think of the proposal.=
 I'm particular interested to know if any compiler has speculatively implem=
ented it so I could play with it but that's probably wishful thinking.</div=
><div><br>On Monday, October 27, 2014 at 9:24:31 PM UTC+13, Ryou Ezoe wrote=
:</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;=
padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;b=
order-left-style:solid">I have some comments on N4165/N4174.
<br>
<br>1. weird code
<br>It's my understanding that under this proposal, following code is well-=
formed.
<br>
<br>4.0.sqrt() ;
<br>"hello".puts() ;
<br>
<br>Is this correct?
<br>
<br>
<br>If so and If we allow N4165's "Additionally allow =E2=80=9Cthis=E2=80=
=9D in not only
<br>the first parameter location",
<br>It does allow this:
<br>
<br>fp-&gt;fputs("hello") ;
<br>
<br>as well as this:
<br>
<br>"hello"-&gt;fputs(fp) ;
<br>
<br>
<br>2. Tool support
<br>The papers wrote about better tool support.
<br>Although I agree with the idea, there are so many too generic function
<br>templates in the standard library that bloat up the auto completion
<br>candidates.
<br>Like move, swap, addressof.
<br>
<br>Without some constrained template features like concept or some hard
<br>coded/heuristic restriction on tool implementation,
<br>a set of auto completion name candidates are indeed smaller than free
<br>functions, but not that small enough.
<br>
<br>Consider FILE from &lt;stdio.h&gt;.
<br>The paper said it can auto complete fseek.
<br>
<br>FILE * fp ;
<br>fp-&gt;fseek
<br>
<br>It looks nice.
<br>
<br>But, Annex D.5 said C headers are deprecated and we should use C++
<br>header(&lt;cstdio&gt;) instead.
<br>So we should write like this:
<br>
<br>std::FILE * fp =3D ... ;
<br>
<br>This add std namespace to fp's associated namespace so all standard
<br>library names are on the candidate list.
<br>
<br>Suppose we also #included &lt;algorithm&gt; and wrote:
<br>
<br>fp-&gt;
<br>
<br>Tool suggest all &lt;algorithm&gt; function templates because fp is a p=
ointer.
<br>
<br>fp-&gt;for_each
<br>
<br>Even if without ADL, id-expression allows qualified-id so a tool just
<br>list up all viable functions:
<br>
<br>fp-&gt;std::for_each
<br>
<br>
<br>This is only considering the standard library, I think users also
<br>wrote many too generic functions like this.
<br>Combining those, auto completion candidates will bloat up with
<br>completely unrelated generic function names user don't expect it to be
<br>suggested.
<br>
<br>
<br>I don't think tool support situation will be any better with this propo=
sal.
<br>It may be worse because candidate bloat up also affect existing class
<br>types and overwhelm the result.
<br>
<br>Very common types(like const char *, long double etc) and class types
<br>which has user defined conversion to common types now shows all sort
<br>of common functions as well as user defined literals!
<br>
<br>long double ld ;
<br>ld.operator "" il() ; // std::complex&lt;long double&gt;
<br>
<br>
<br>What do you think?
<br>
<br>--=20
<br>Ryou Ezoe
<br>
<br>Occupation: DWANGO Co., Ltd.
<br>
<br>Blog: &nbsp; &nbsp; <a href=3D"http://cpplover.blogspot.com/" rel=3D"no=
follow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com=
/url?q\75http%3A%2F%2Fcpplover.blogspot.com%2F\46sa\75D\46sntz\0751\46usg\7=
5AFQjCNFB9njSrdJmdDtzuKxuJVRjkMk6cQ';return true;" onclick=3D"this.href=3D'=
http://www.google.com/url?q\75http%3A%2F%2Fcpplover.blogspot.com%2F\46sa\75=
D\46sntz\0751\46usg\75AFQjCNFB9njSrdJmdDtzuKxuJVRjkMk6cQ';return true;">htt=
p://cpplover.blogspot.com/</a>
<br>Twitter: <a href=3D"https://twitter.com/EzoeRyou" rel=3D"nofollow" targ=
et=3D"_blank" onmousedown=3D"this.href=3D'https://www.google.com/url?q\75ht=
tps%3A%2F%2Ftwitter.com%2FEzoeRyou\46sa\75D\46sntz\0751\46usg\75AFQjCNELTFV=
Rb6q-vfMMeNdx0ngU0b9vog';return true;" onclick=3D"this.href=3D'https://www.=
google.com/url?q\75https%3A%2F%2Ftwitter.com%2FEzoeRyou\46sa\75D\46sntz\075=
1\46usg\75AFQjCNELTFVRb6q-vfMMeNdx0ngU0b9vog';return true;">https://twitter=
..com/EzoeRyou</a>
<br>GitHub: <a href=3D"https://github.com/EzoeRyou" rel=3D"nofollow" target=
=3D"_blank" onmousedown=3D"this.href=3D'https://www.google.com/url?q\75http=
s%3A%2F%2Fgithub.com%2FEzoeRyou\46sa\75D\46sntz\0751\46usg\75AFQjCNGW0LevPY=
eWQJpnehARuyNuugly6w';return true;" onclick=3D"this.href=3D'https://www.goo=
gle.com/url?q\75https%3A%2F%2Fgithub.com%2FEzoeRyou\46sa\75D\46sntz\0751\46=
usg\75AFQjCNGW0LevPYeWQJpnehARuyNuugly6w';return true;">https://github.com/=
EzoeRyou</a>
<br></blockquote></div></blockquote></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_3694_812004657.1425341266670--
------=_Part_3693_576688624.1425341266670--

.
