220 18822 <CA+jCFLv9HQ6prPgocPR_6u7FA9HYT6qwZ8_yDzFNQrBJAw7d3g@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Christopher Jefferson <chris@bubblescope.net>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Compressing std::optional
Date: Fri, 26 Jun 2015 23:41:38 +0100
Lines: 188
Approved: news@gmane.org
Message-ID: <CA+jCFLv9HQ6prPgocPR_6u7FA9HYT6qwZ8_yDzFNQrBJAw7d3g@mail.gmail.com>
References: <4359ebfb-5e20-42c1-84a0-16ef6201db33@isocpp.org>
	<33303ec4-d4c3-4080-a7bb-346496e38114@isocpp.org>
	<CA+jCFLu=mau8v+XJxAg7eUwk=uLXdXLhhGTV9KsOxT=CjtzqfQ@mail.gmail.com>
	<CAOHCbiv9J9S=U02d=P3jrDN8WD1dLpoWsfz3Jmot7LV7JHQAVw@mail.gmail.com>
	<CA+jCFLtsxoyM2s5+hnkwGGYpBNyRAtbxfLROaNTTG67oQ-S5PQ@mail.gmail.com>
	<CAOHCbiuVSA9fWZrH1h-ZGjKU9C83DJabAn+EiW5M0OU6B9C_=g@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a113496d0737a2b0519737111
X-Trace: ger.gmane.org 1435358509 28933 80.91.229.3 (26 Jun 2015 22:41:49 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 26 Jun 2015 22:41:49 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCF5NPH6QMFRBJFKW6WAKGQEQJSODCI@isocpp.org Sat Jun 27 00:41:45 2015
Return-path: <std-proposals+bncBCF5NPH6QMFRBJFKW6WAKGQEQJSODCI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-la0-f71.google.com ([209.85.215.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCF5NPH6QMFRBJFKW6WAKGQEQJSODCI@isocpp.org>)
	id 1Z8cJZ-00011n-Sx
	for gclcip-std-proposals@m.gmane.org; Sat, 27 Jun 2015 00:41:41 +0200
Original-Received: by laar3 with SMTP id r3sf30163443laa.1
        for <gclcip-std-proposals@m.gmane.org>; Fri, 26 Jun 2015 15:41:41 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:content-type: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=5Wx3K8yhSt8ZNG/MvFg6SpGD1cc1HqJppebWezO46C4=;
        b=Ag8PR8PI+yLYoOPY9M5BMbOGb9sA1QmpI1KSWzLi8g75xqqRU+xWRHT85j23XfiZd8
         ZrsgEdwsLxQNORDa4WK10+D9WLm9EGOthCpkd+z5v2PF2ro55BdxbN/4MWF1Rft2K4zN
         7S1y2N6RnRoWFVlc41kyDbeQBo8g9zZYDtcLGXZB3DGsFJPPlPoMvwu9exfERKEdP3zu
         NgFumaJuSQJeKFmubFi9om+BtnTHnOIFmq6J/cRwHeJ4GolB/J9qadbWUG9Ux78FURcy
         HOPndQy4MnX486pm8ePcacwLETcXQPudg+pcU14PRepEnBfHY+8iW3DyIs17xiKU1iVD
         SFxw==
X-Gm-Message-State: ALoCoQlAOmOuwH5zfHdot1qw9uPSPVB134Go2w96BvqcrQ/kqDbApbAZn7BPZCLyIPMG1sS3QE+l
X-Received: by 10.180.37.198 with SMTP id a6mr299878wik.7.1435358501391;
        Fri, 26 Jun 2015 15:41:41 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.7.146 with SMTP id j18ls585582laa.22.gmail; Fri, 26 Jun
 2015 15:41:39 -0700 (PDT)
X-Received: by 10.112.61.132 with SMTP id p4mr3632480lbr.48.1435358499493;
        Fri, 26 Jun 2015 15:41:39 -0700 (PDT)
Original-Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43])
        by mx.google.com with ESMTPS id sc4si28553843lbb.99.2015.06.26.15.41.39
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 26 Jun 2015 15:41:39 -0700 (PDT)
Received-SPF: neutral (google.com: 209.85.215.43 is neither permitted nor denied by best guess record for domain of chris@bubblescope.net) client-ip=209.85.215.43;
Original-Received: by lagi2 with SMTP id i2so71551974lag.2
        for <std-proposals@isocpp.org>; Fri, 26 Jun 2015 15:41:39 -0700 (PDT)
X-Received: by 10.152.246.37 with SMTP id xt5mr3580819lac.83.1435358498872;
 Fri, 26 Jun 2015 15:41:38 -0700 (PDT)
Original-Received: by 10.112.13.198 with HTTP; Fri, 26 Jun 2015 15:41:38 -0700 (PDT)
Original-Received: by 10.112.13.198 with HTTP; Fri, 26 Jun 2015 15:41:38 -0700 (PDT)
In-Reply-To: <CAOHCbiuVSA9fWZrH1h-ZGjKU9C83DJabAn+EiW5M0OU6B9C_=g@mail.gmail.com>
X-Original-Sender: chris@bubblescope.net
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 209.85.215.43 is neither permitted nor denied by best guess
 record for domain of chris@bubblescope.net) smtp.mail=chris@bubblescope.net
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: <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:18822
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/18822>

--001a113496d0737a2b0519737111
Content-Type: text/plain; charset=UTF-8

On 26 Jun 2015 10:25 pm, "Tony V E" <tvaneerd@gmail.com> wrote:
>
>
>> >> I have used an 'optimised optional' of the type suggested in this
>> >> paper for years. At some point I decided to forbid this case -- a user
>> >> should be completely unable to tell any space optimisation is being
>> >> performed (except the object is smaller obviously). That does mean you
>> >> can't compress types such as int or double.
>> >>
>> >> Chris
>> >
>> >
>> > In what cases *can* you compress then?
>>
>> Any type where at least one bit pattern isn't used in a valid object.
>>
>> Personally, I mainly compress containers (std::vector, std::list,
>> std::map, etc.).
>>
>> I know on any system I care about malloc is never going to return
>> (void*)1, so any object which contains a pointer can assign that value
>> to a pointer to represent disengaged.
>>
>> Chris
>
>
> but how do you know that in my usage of optional<void*>, I also use
(void*)1 for special meaning (besides the use inside optional).
> ie I can still have:
>
> void * some_function(); // returns (void*)1 in some case
>
> optional<void *> ov = some_function();
>
> assert( ! ov.empty() );
>
> ie you still need to know the problem domain.  Same as using NaN or 0 or
whatever.
> The user can still "tell" the optimization exists.  Or, more likely, trip
over in some rare case.
>
> I think it is valuable to hear that you have experience with a compressed
optional, but I wonder if the eventual answer is that you would abandon it
completely.
>
> And/or although it may be reasonable to assume your code base need not
worry about (void *)1, the standard has a larger codebase to consider.

I certainly wouldn't compress optional<void*> for the reasons you outline,
but within STD::vector, I might know more, such as promises about the
alignment of memory, or knowledge of STD::allocator.

In the case of vector, in GCC there are 3 pointers start, end, capacity
which satisfy start <= end <= capacity. I can therefore easily make a never
occurring state by assigning start > end.

I am going to think more carefully about the nan-compression case given
earlier. I would not put it in the standard, but I can see the benefit of
letting users write it -- if they then assign a nan they are in trouble,
but that is their own fault!

> --
>
> ---
> 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.
> Visit this group at
http://groups.google.com/a/isocpp.org/group/std-proposals/.

-- 

--- 
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a113496d0737a2b0519737111
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p dir=3D"ltr"><br>
On 26 Jun 2015 10:25 pm, &quot;Tony V E&quot; &lt;<a href=3D"mailto:tvaneer=
d@gmail.com">tvaneerd@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;&gt; &gt;&gt; I have used an &#39;optimised optional&#39; of the type s=
uggested in this<br>
&gt;&gt; &gt;&gt; paper for years. At some point I decided to forbid this c=
ase -- a user<br>
&gt;&gt; &gt;&gt; should be completely unable to tell any space optimisatio=
n is being<br>
&gt;&gt; &gt;&gt; performed (except the object is smaller obviously). That =
does mean you<br>
&gt;&gt; &gt;&gt; can&#39;t compress types such as int or double.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Chris<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; In what cases *can* you compress then?<br>
&gt;&gt;<br>
&gt;&gt; Any type where at least one bit pattern isn&#39;t used in a valid =
object.<br>
&gt;&gt;<br>
&gt;&gt; Personally, I mainly compress containers (std::vector, std::list,<=
br>
&gt;&gt; std::map, etc.).<br>
&gt;&gt;<br>
&gt;&gt; I know on any system I care about malloc is never going to return<=
br>
&gt;&gt; (void*)1, so any object which contains a pointer can assign that v=
alue<br>
&gt;&gt; to a pointer to represent disengaged.<br>
&gt;&gt;<br>
&gt;&gt; Chris<br>
&gt;<br>
&gt;<br>
&gt; but how do you know that in my usage of optional&lt;void*&gt;, I also =
use (void*)1 for special meaning (besides the use inside optional).<br>
&gt; ie I can still have:<br>
&gt;<br>
&gt; void * some_function(); // returns (void*)1 in some case<br>
&gt;<br>
&gt; optional&lt;void *&gt; ov =3D some_function();<br>
&gt;<br>
&gt; assert( ! ov.empty() );<br>
&gt;<br>
&gt; ie you still need to know the problem domain.=C2=A0 Same as using NaN =
or 0 or whatever.<br>
&gt; The user can still &quot;tell&quot; the optimization exists.=C2=A0 Or,=
 more likely, trip over in some rare case.<br>
&gt;<br>
&gt; I think it is valuable to hear that you have experience with a compres=
sed optional, but I wonder if the eventual answer is that you would abandon=
 it completely.<br>
&gt;<br>
&gt; And/or although it may be reasonable to assume your code base need not=
 worry about (void *)1, the standard has a larger codebase to consider.</p>
<p dir=3D"ltr">I certainly wouldn&#39;t compress optional&lt;void*&gt; for =
the reasons you outline, but within STD::vector, I might know more, such as=
 promises about the alignment of memory, or knowledge of STD::allocator.</p=
>
<p dir=3D"ltr">In the case of vector, in GCC there are 3 pointers start, en=
d, capacity which satisfy start &lt;=3D end &lt;=3D capacity. I can therefo=
re easily make a never occurring state by assigning start &gt; end.</p>
<p dir=3D"ltr">I am going to think more carefully about the nan-compression=
 case given earlier. I would not put it in the standard, but I can see the =
benefit of letting users write it -- if they then assign a nan they are in =
trouble, but that is their own fault!</p>
<p dir=3D"ltr">&gt; -- <br>
&gt;<br>
&gt; --- <br>
&gt; You received this message because you are subscribed to the Google Gro=
ups &quot;ISO C++ Standard - Future Proposals&quot; group.<br>
&gt; To unsubscribe from this group and stop receiving emails from it, send=
 an email to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-=
proposals+unsubscribe@isocpp.org</a>.<br>
&gt; To post to this group, send email to <a href=3D"mailto:std-proposals@i=
socpp.org">std-proposals@isocpp.org</a>.<br>
&gt; Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/g=
roup/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-propos=
als/</a>.<br>
</p>

<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 />

--001a113496d0737a2b0519737111--

.
