220 9289 <4334336c-32c3-4984-8bf1-c9442ed85b9a@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Andrew Tomazos <andrewtomazos@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Precise Per-Type Cyclic Garbage Collection (DRAFT 1)
Date: Tue, 11 Feb 2014 11:25:49 -0800 (PST)
Lines: 180
Approved: news@gmane.org
Message-ID: <4334336c-32c3-4984-8bf1-c9442ed85b9a@isocpp.org>
References: <d1cac476-349d-4fe9-a0a4-98f8a4378a3a@isocpp.org>
 <CAOU91OOUfEMesNzJUgXhHNh16R7nm00yhMrOk_vLamvB+gbQZQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_4975_28612542.1392146749376"
X-Trace: ger.gmane.org 1392146746 22669 80.91.229.3 (11 Feb 2014 19:25:46 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 11 Feb 2014 19:25:46 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD5KHQXXWYPRBQHS5GLQKGQEOYUQTQA@isocpp.org Tue Feb 11 20:25:55 2014
Return-path: <std-proposals+bncBD5KHQXXWYPRBQHS5GLQKGQEOYUQTQA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yk0-f198.google.com ([209.85.160.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD5KHQXXWYPRBQHS5GLQKGQEOYUQTQA@isocpp.org>)
	id 1WDIxt-00060V-Ti
	for gclcip-std-proposals@m.gmane.org; Tue, 11 Feb 2014 20:25:54 +0100
Original-Received: by mail-yk0-f198.google.com with SMTP id 131sf24321807ykp.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 11 Feb 2014 11:25:53 -0800 (PST)
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
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=+5Q0hPWqkMjPycqRgUnuE40vWf940+bPgwCePAQD5IY=;
        b=n3OmTONLbxthS4qWBSPYNiLewsn0HZggMmSScy8jxo0/5wV+5H6esI5ZQtJrL+KZsy
         DOcptBBjuu3N4zCDixDQVk7ORVGARSV0pi5Ozs/MQyu1NkMepd1rJT6j7/JVIYiYzICw
         rnz/16tIGuxZ94hcFrehoggxAa/+pdpg2e21wDF9M0tiLefgMGiAI60xVZgz1Yuu9swk
         9E470uVZpWQjF15C8D6ZcipGPww0f3tqhY8EzfDLGh/iZGiaHa9xMfWxBp82gcuu911p
         GzfzZMoogvcoEJJOf1RYBuemaIBt8Sp7rAdVQ/UtG+oFtn7m+4epK23vwh+1eCW1T6ik
         gT5w==
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:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=+5Q0hPWqkMjPycqRgUnuE40vWf940+bPgwCePAQD5IY=;
        b=YfGdLpV0VgYNOV2VFIbhSk0fXorNlZlxkOmTxA81DHYeTDURiLN/wZSeE7W4+Y3lkU
         nxFp0WQCRfmz3tEipPuLZzFEl2Qm2EmoBKHJWpfnW7dbK/vARRZu2msqITqnB16104+K
         R/RT9n0YIbLyMMmeuEAk0L8s2tRGyO5e6iOIz8xvxW5v0hTfnf3T20etLljj6mTWCeUP
         bkMU3NlqB76VCAsU0VfXxSE/ruhakLeJtRTrvY9WI0CtMoU2TVsZ7SFe/nnqApHXJf4u
         +AylQDRDypCaoQ9icjvZMT/53pn11HM3y59bXF8+bu7aMLtCFyOIu5v5bNh1pp3d/njP
         Q6ZA==
X-Gm-Message-State: ALoCoQmBma9nzDsfOwP0CP+A1qe2JwZdnokgncjSSYLWtkWYy49uLQrGwiwfC2INh5oqF523e5x1
X-Received: by 10.236.133.82 with SMTP id p58mr51178yhi.37.1392146752981;
        Tue, 11 Feb 2014 11:25:52 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.81.209 with SMTP id f75ls2552904qgd.48.gmail; Tue, 11 Feb
 2014 11:25:50 -0800 (PST)
X-Received: by 10.140.34.147 with SMTP id l19mr45081qgl.30.1392146749965;
        Tue, 11 Feb 2014 11:25:49 -0800 (PST)
In-Reply-To: <CAOU91OOUfEMesNzJUgXhHNh16R7nm00yhMrOk_vLamvB+gbQZQ@mail.gmail.com>
X-Original-Sender: andrewtomazos@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: <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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:9289
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/9289>

------=_Part_4975_28612542.1392146749376
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tuesday, February 11, 2014 7:34:52 PM UTC+1, Klaim - Jo=C3=ABl Lamotte w=
rote:
>
> 1. This proposal is about a language extension, but seems (if I didn't=20
> miss anything) to ignore C++11 minimal garbage collection hooks
>     as explained by Stroustrup there:=20
> http://www.stroustrup.com/C++11FAQ.html#gc-abi
>     Did you take this into account?
>

Yes.  The safely-derived pointer concept is designed for program-wide=20
conservative collection such as the Boehm collector.  This proposal is for=
=20
nominating specific types for collection by a precise collector.=20
 Collecting pointers are even more constrained than safely-derived=20
pointers, and they are better as the constraints on collecting pointers are=
=20
enforced at compile-time.
=20

> 2. Acronyms are harder to interpret, even in this case.
>     Instead of 'gc', I would suggest 'collected' (which is the adjective=
=20
> you use to describe what the keyword does to the type)
>
=20
Noted.  To be considered.

3. How do you expect generic algorithm developers to work with types which=
=20
> can't be manipulated through iterators/ranges?
>

Integration with collections and algorithms needs some study, but the=20
initial idea is that you use pointer to T rather than T itself.  So for=20
example:

    vector<foo*> v =3D ...;

    for (auto x : v)
        x->do_something();

Clearly this doesn't work easily with user-defined equality, hashing and=20
comparison - this is no different than the situation today with pointers,=
=20
unique_ptrs or shared_ptrs.

But having said that - since posting the proposal I have come up with a=20
pretty radical idea of how to deal with this, but it is quite difficult to=
=20
explain and I need to work through the ramifications.  To try to summarize=
=20
it (and fail), a collected type will be a "handle" type.  It will store its=
=20
data members within an unnamed struct, and it will have one "hidden"=20
implicit member that is a pointer to that struct.  That way, what we call=
=20
in the original proposal a collecting pointer (foo*) will now be the=20
collected type itself (foo), and what was the collected type (foo) is now=
=20
an unnamed struct.  Within its member functions, the this pointer is set to=
=20
the implicit pointer member for looking up data members.  So from within=20
the class specifier it will look like you are defining a normal type and=20
you can use it mostly as normal, but when you copy construct it, it will be=
=20
a handle to the same instance.  The collection graph is then traced the=20
same way, except using these implicit pointer members and unnamed structs,=
=20
rather than the collecting pointers and collected types.  I have to double=
=20
check that this isn't completely insane, and if you couldn't follow what I=
=20
just said, I don't blame you.

4. Did you consider attaching the garbage collecting logic to specific=20
> instances instead of types?
>

Yes.  It doesn't seem to work as well.  If the entire type is nominated,=20
things seem to work out much cleaner.

--=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_4975_28612542.1392146749376
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, February 11, 2014 7:34:52 PM UTC+1, Klaim - Jo=
=C3=ABl Lamotte 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"ltr"><div>1. This proposal is about a language extension, but seems (if=
 I didn't miss anything) to ignore C++11 minimal garbage collection hooks<b=
r></div>
<div>&nbsp; &nbsp; as explained by Stroustrup there:&nbsp;<a href=3D"http:/=
/www.stroustrup.com/C++11FAQ.html#gc-abi" target=3D"_blank" onmousedown=3D"=
this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.stroustrup.com%=
2FC%2B%2B11FAQ.html%23gc-abi\46sa\75D\46sntz\0751\46usg\75AFQjCNEEb2g2Rql1G=
SPp6loHNkBQxPETVg';return true;" onclick=3D"this.href=3D'http://www.google.=
com/url?q\75http%3A%2F%2Fwww.stroustrup.com%2FC%2B%2B11FAQ.html%23gc-abi\46=
sa\75D\46sntz\0751\46usg\75AFQjCNEEb2g2Rql1GSPp6loHNkBQxPETVg';return true;=
">http://www.stroustrup.<wbr>com/C++11FAQ.html#gc-abi</a><br>&nbsp; &nbsp; =
Did you take this into account?<br></div></div></blockquote><div><br></div>=
<div>Yes. &nbsp;The safely-derived pointer concept is designed for program-=
wide conservative collection such as the Boehm collector. &nbsp;This propos=
al is for nominating specific types for collection by a precise collector. =
&nbsp;Collecting pointers are even more constrained than safely-derived poi=
nters, and they are better as the constraints on collecting pointers are en=
forced at compile-time.</div><div>&nbsp;</div><blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padd=
ing-left: 1ex;"><div dir=3D"ltr"><div>2. Acronyms are harder to interpret, =
even in this case.<br>
&nbsp; &nbsp; Instead of 'gc', I would suggest 'collected' (which is the ad=
jective you use to describe what the keyword does to the type)</div></div><=
/blockquote><div>&nbsp;</div><div>Noted. &nbsp;To be considered.</div><div>=
<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"ltr"><di=
v></div><div>3. How do you expect generic algorithm developers to work with=
 types which can't be manipulated through iterators/ranges?</div></div></bl=
ockquote><div><br></div><div>Integration with collections and algorithms ne=
eds some study, but the initial idea is that you use pointer to T rather th=
an T itself. &nbsp;So for example:</div><div><br></div><div>&nbsp; &nbsp; v=
ector&lt;foo*&gt; v =3D ...;</div><div><br></div><div>&nbsp; &nbsp; for (au=
to x : v)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; x-&gt;do_something();</div>=
<div><br></div><div>Clearly this doesn't work easily with user-defined equa=
lity, hashing and comparison - this is no different than the situation toda=
y with pointers, unique_ptrs or shared_ptrs.</div><div><br></div><div>But h=
aving said that - since posting the proposal I have come up with a pretty r=
adical idea of how to deal with this, but it is quite difficult to explain =
and I need to work through the ramifications. &nbsp;To try to summarize it =
(and fail), a collected type will be a "handle" type. &nbsp;It will store i=
ts data members within an unnamed struct, and it will have one "hidden" imp=
licit member that is a pointer to that struct. &nbsp;That way, what we call=
 in the original proposal a collecting pointer (foo*) will now be the colle=
cted type itself (foo), and what was the collected type (foo) is now an unn=
amed struct. &nbsp;Within its member functions, the this pointer is set to =
the implicit pointer member for looking up data members. &nbsp;So from with=
in the class specifier it will look like you are defining a normal type and=
 you can use it mostly as normal, but when you copy construct it, it will b=
e a handle to the same instance. &nbsp;The collection graph is then traced =
the same way, except using these implicit pointer members and unnamed struc=
ts, rather than the collecting pointers and collected types. &nbsp;I have t=
o double check that this isn't completely insane, and if you couldn't follo=
w what I just said, I don't blame you.</div><div><br></div><blockquote clas=
s=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #c=
cc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>4. Did you consider atta=
ching the garbage collecting logic to specific instances instead of types?<=
/div></div></blockquote><div><br></div><div>Yes. &nbsp;It doesn't seem to w=
ork as well. &nbsp;If the entire type is nominated, things seem to work out=
 much cleaner.</div><div><br></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_4975_28612542.1392146749376--

.
