220 34537 <c93b4603-ff34-495f-bcd5-c844e8ee0eec@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Niall Douglas <nialldouglas14@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: base and self built-in keywords
Date: Mon, 2 Oct 2017 07:29:03 -0700 (PDT)
Lines: 201
Approved: news@gmane.org
Message-ID: <c93b4603-ff34-495f-bcd5-c844e8ee0eec@isocpp.org>
References: <ad3fa9d9-b3d1-4650-84bd-d3f6931c9033@isocpp.org>
 <f006604b-cdec-4933-8a79-eb9b25716c7e@isocpp.org>
 <9dec3353-3142-43d1-928f-b88ac74951bf@isocpp.org>
 <63cb64a8-5add-45ff-a856-364d37042b44@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_5247_125774284.1506954543345"
X-Trace: blaine.gmane.org 1506954546 19183 195.159.176.226 (2 Oct 2017 14:29:06 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 2 Oct 2017 14:29:06 +0000 (UTC)
Cc: sergeikrivonos@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDGKFT5YZADRBME2ZHHAKGQEVTALFEI@isocpp.org Mon Oct 02 16:29:00 2017
Return-path: <std-proposals+bncBDGKFT5YZADRBME2ZHHAKGQEVTALFEI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f199.google.com ([209.85.220.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDGKFT5YZADRBME2ZHHAKGQEVTALFEI@isocpp.org>)
	id 1dz1iM-0004LR-8B
	for gclcip-std-proposals@m.gmane.org; Mon, 02 Oct 2017 16:28:58 +0200
Original-Received: by mail-qk0-f199.google.com with SMTP id c67sf4437510qkg.18
        for <gclcip-std-proposals@m.gmane.org>; Mon, 02 Oct 2017 07:29:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc: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=brMWeH34nKZoSuUhs4T8xgAcYa9od6PHlfB0sVQXLRI=;
        b=rI3ETNTgzdXc3nFVtfznpics1kX5j9mJwihDWQXxwqMMJzKATg5HiTv3mXtIWweELl
         ONM3VU+8+W4I751a6TWnZ2PHM9lu7PauRt2reftK9TLnoXrrAb/uFxLlzWGshVfrrtcf
         i88kD5bDzcaLxM0w2A7dxz84ayA7JLcuKvpjFOVPsP4g4dTlbXHO3o7UEVnXZdMc71rH
         W+UPjBoKwvcCdyVBZ+bn31ipW2v+v3htJw/1X+sBiD9ATwdEgKIGoq9zoNh4FgWwgslr
         d7pTAdMFP/25DJslZZ16megZ2cIs/7uaNgeo84ixXKFsRpcsLSFqYfF/qGYCQv2FTznn
         A84A==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:cc: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=brMWeH34nKZoSuUhs4T8xgAcYa9od6PHlfB0sVQXLRI=;
        b=Hzk8ElGLYVTsIiT7pGGXRGv56lN2Jz1DF9wBo2NYxor/lW0sbIq1iKQg1FWKAEXgua
         aExOPFaZbrV7ylAG8mRBgF4x5TMGxvvh8xLOHjSkzYE/BGY1BMdeK4UjdQWw4Q0F2exS
         DI1gVl6+mG0BV8/tOaqV7ALWUNMHPiLYaRxFDfUyOfhi4INQKKcvXbmIDDO0xsDFlLKd
         56gxScS68SAszOS6VmKbs5JOJpL8M6WpK2nrFV6sWxWQSyyeswFgxnVEfO2NqxU7bLoY
         yTITMUXMcAIEupe3RrTAZPkiM+6z1uo4Fi7ltetWRfntLs0ZXfm6lxQKJRPHAtLQ5eot
         34qg==
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:cc: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=brMWeH34nKZoSuUhs4T8xgAcYa9od6PHlfB0sVQXLRI=;
        b=IwGc0YtZ/a0Z2MwwjhMltZ3mVwg+3o2d0BblTP18OPlqB70xff5hNZDK3U45IFPvE4
         9h+cJRcQQhurexmal9ppq4QsvwgV++MsuKQUilMHmPFkxVQHvaq5+DYw69l/UWCJKDSt
         UzY0DLIIhZ2DLLn1UZ2l6ArIbGMtSS1a51Dnnuymo5KBjhk+CkKBiJrg2XLYaChltE6l
         z1k4mMvXkJRE325n4pYRspBVdI6r559IeaWdmT4x2sDsiGkk09yOH07EFkEqnkCDa0NA
         n945jgOCDl0MYbOnlN6Bn4+E3YOjlSgHLkoLXd+ozpQxRWfOnPwChKzeoJGWN059ecUP
         1QGA==
X-Gm-Message-State: AHPjjUg5CvPZ3btd28KUFJAvek0bVsYI8TV0zENMLP3/o6fKKZDdnPMn
	E28ZKJKKoR+QZGe3ee/7a4c5EQ==
X-Google-Smtp-Source: AOwi7QAqzdbJqX0SvPwk35PYGgEWwMjzwsZi576OV/ewm3Y7DLczfP1Ep9ME2hy8FFeIV5mnGiZSLA==
X-Received: by 10.176.17.234 with SMTP id q42mr3306332uac.21.1506954545511;
        Mon, 02 Oct 2017 07:29:05 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.114.203 with SMTP id n194ls3542860vkc.0.gmail; Mon, 02 Oct
 2017 07:29:03 -0700 (PDT)
X-Received: by 10.31.199.2 with SMTP id x2mr674160vkf.17.1506954543867;
        Mon, 02 Oct 2017 07:29:03 -0700 (PDT)
In-Reply-To: <63cb64a8-5add-45ff-a856-364d37042b44@isocpp.org>
X-Original-Sender: nialldouglas14@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:34537
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/34537>

------=_Part_5247_125774284.1506954543345
Content-Type: multipart/alternative; 
	boundary="----=_Part_5248_680863879.1506954543346"

------=_Part_5248_680863879.1506954543346
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable


>
>
>>>
>>> Python supports multiple inheritance too and I'd suggest you clone thei=
r=20
>> super() function rather than invent anything new.
>>
>
> Oh dear. Literally anything would be better than Python's super() functio=
n.
> Python invents a sort of linearization of the multiple-inheritance tree (=
the=20
> MRO <https://www.python.org/download/releases/2.3/mro/>) so that you can=
=20
> manually call super-class __init__ routines (or not) as you choose; i.e.,=
=20
> Python does not have the concept of "constructor" as we understand it in=
=20
> C++. It's more like Objective-C's init routines.
>

A more accurate explanation is that super() would return the native vtable=
=20
for the selected inherited class.
=20

> In my experience it's basically impossible to use correctly; if you're=20
> doing multiple inheritance in Python you're *probably* doing something=20
> wrong whether you're aware of it or not.
> (In Python 2 super() requires repeating the name of your own class anyway=
,=20
> where repetition of class names was the original problem OP wanted to=20
> solve. But I see that the repetition has been dropped from Python 3 =E2=
=80=94 cool! This=20
> tutorial=20
> <http://www.pythonforbeginners.com/super/working-python-super-function>=
=20
> seems fair and balanced to me, and covers the syntax in both dialects of=
=20
> Python.)
>

Multiple inheritance is exactly as useful in Python as in C++. Usually best=
=20
sparingly, but when it's useful, it's useful, plus the same metaprogramming=
=20
tricks are available in Python's multiple inheritance as in C++. And I've=
=20
seen no trouble in using it correctly, you can have recursive nestings of=
=20
eval() specialised fragments assembled together and it all works fine,=20
including super() to traverse the hierarchy.

Python's really great. Such a deep well of evil power available to the=20
programmer.
=20

> This blog post <http://www.artima.com/weblogs/viewpost.jsp?thread=3D23627=
5>=20
> points out something I'd never consciously considered before: Python has =
no=20
> non-virtual inheritance (I think?).=20
>

More that virtual inheritance is the default for all member functions. You=
=20
need to explicitly ask to call a non-virtualised implementation, which is=
=20
via super() actually.
=20

>
> Anyway, I don't think there's any problem to be solved here. Certainly I=
=20
> don't think C++ should introduce any special syntax for the "I'th base=20
> class." If you want something like that, you probably want Herb Sutter's=
=20
> metaclasses (or better) anyway.
>

Reserving self and base for Herb's metaclasses, now that is something I can=
=20
agree 110% with.

Niall

--=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/c93b4603-ff34-495f-bcd5-c844e8ee0eec%40isocpp.or=
g.

------=_Part_5248_680863879.1506954543346
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div dir=3D"ltr"><blockquote class=3D"gmail_quot=
e" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-l=
eft:1ex"><div dir=3D"ltr"><br><br></div></blockquote><div>Python supports m=
ultiple inheritance too and I&#39;d suggest you clone their super() functio=
n rather than invent anything new.</div></div></blockquote><div><br></div><=
div>Oh dear. Literally anything would be better than Python&#39;s super() f=
unction.</div><div>Python invents a sort of linearization of the multiple-i=
nheritance tree (<a href=3D"https://www.python.org/download/releases/2.3/mr=
o/" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http=
s://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.python.org%2Fdownload%2Frelea=
ses%2F2.3%2Fmro%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE0rDP30INlMrF_FC=
Wcg5gY8zLPIg&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.goo=
gle.com/url?q\x3dhttps%3A%2F%2Fwww.python.org%2Fdownload%2Freleases%2F2.3%2=
Fmro%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE0rDP30INlMrF_FCWcg5gY8zLPI=
g&#39;;return true;">the MRO</a>) so that you can manually call super-class=
 __init__ routines (or not) as you choose; i.e., Python does not have the c=
oncept of &quot;constructor&quot; as we understand it in C++. It&#39;s more=
 like Objective-C&#39;s init routines.</div></div></blockquote><div><br></d=
iv><div>A more accurate explanation is that super() would return the native=
 vtable for the selected inherited class.</div><div>=C2=A0</div><blockquote=
 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> In my experience i=
t&#39;s basically impossible to use correctly; if you&#39;re doing multiple=
 inheritance in Python you&#39;re <i>probably</i> doing something wrong whe=
ther you&#39;re aware of it or not.</div><div>(In Python 2=C2=A0super() req=
uires repeating the name of your own class anyway, where repetition of clas=
s names was the original problem OP wanted to solve. But I see that the rep=
etition has been dropped from Python 3 =E2=80=94 cool! <a href=3D"http://ww=
w.pythonforbeginners.com/super/working-python-super-function" target=3D"_bl=
ank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.com=
/url?q\x3dhttp%3A%2F%2Fwww.pythonforbeginners.com%2Fsuper%2Fworking-python-=
super-function\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEHgAzdF0WqOSOff48kwe=
dor4v8YQ&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.c=
om/url?q\x3dhttp%3A%2F%2Fwww.pythonforbeginners.com%2Fsuper%2Fworking-pytho=
n-super-function\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEHgAzdF0WqOSOff48k=
wedor4v8YQ&#39;;return true;">This tutorial</a> seems fair and balanced to =
me, and covers the syntax in both dialects of Python.)</div></div></blockqu=
ote><div><br></div><div>Multiple inheritance is exactly as useful in Python=
 as in C++. Usually best sparingly, but when it&#39;s useful, it&#39;s usef=
ul, plus the same metaprogramming tricks are available in Python&#39;s mult=
iple inheritance as in C++. And I&#39;ve seen no trouble in using it correc=
tly, you can have recursive nestings of eval() specialised fragments assemb=
led together and it all works fine, including super() to traverse the hiera=
rchy.</div><div><br></div><div>Python&#39;s really great. Such a deep well =
of evil power available to the programmer.</div><div>=C2=A0</div><blockquot=
e class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: =
1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><a href=3D"http://=
www.artima.com/weblogs/viewpost.jsp?thread=3D236275" target=3D"_blank" rel=
=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x=
3dhttp%3A%2F%2Fwww.artima.com%2Fweblogs%2Fviewpost.jsp%3Fthread%3D236275\x2=
6sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFx_ydJrEptLhUxT6CmKOzSbJIi2w&#39;;ret=
urn true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%=
3A%2F%2Fwww.artima.com%2Fweblogs%2Fviewpost.jsp%3Fthread%3D236275\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNFx_ydJrEptLhUxT6CmKOzSbJIi2w&#39;;return tru=
e;">This blog post</a> points out something I&#39;d never consciously consi=
dered before: Python has no non-virtual inheritance (I think?). </div></div=
></blockquote><div><br></div><div>More that virtual inheritance is the defa=
ult for all member functions. You need to explicitly ask to call a non-virt=
ualised implementation, which is via super() actually.</div><div>=C2=A0</di=
v><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;b=
order-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><br></=
div><div>Anyway, I don&#39;t think there&#39;s any problem to be solved her=
e. Certainly I don&#39;t think C++ should introduce any special syntax for =
the &quot;I&#39;th base class.&quot; If you want something like that, you p=
robably want Herb Sutter&#39;s metaclasses (or better) anyway.</div></div><=
/blockquote><div><br></div><div>Reserving self and base for Herb&#39;s meta=
classes, now that is something I can agree 110% with.</div><div><br></div><=
div>Niall</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/c93b4603-ff34-495f-bcd5-c844e8ee0eec%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c93b4603-ff34-495f-bcd5-c844e8ee0eec=
%40isocpp.org</a>.<br />

------=_Part_5248_680863879.1506954543346--

------=_Part_5247_125774284.1506954543345--

.
