220 2479 <7d4c0427-7818-41ea-bbb9-bf3e149c2882@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Vincent Jacquet <vjacquet@flowgroup.fr>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: optional<T>, one more value or two states
Date: Tue, 29 Jan 2013 02:18:02 -0800 (PST)
Lines: 144
Approved: news@gmane.org
Message-ID: <7d4c0427-7818-41ea-bbb9-bf3e149c2882@isocpp.org>
References: <CAGsORuC1ADLXgS9AZZiTo=knmhT-+9Yj+82v+b8Nq_WJpb1fOg@mail.gmail.com>
 <CAFk2RUZyZA0LLUNuVNcnibv+qBF69jMytWQL3tkp-Kp21oEU+A@mail.gmail.com>
 <CAGsORuB-Qkx-LaXj2jO4yLrwN524kiJONSg7oczkQZHYaJ6ASg@mail.gmail.com>
 <d360a952-28ae-4d57-bb20-96fd08725a0b@isocpp.org>
 <CAPXezF_JggyMaXjGS9r1EAGVu1NhQBEyGEXB8tKmVqgFfjoCeg@mail.gmail.com>
 <CALJmx62zJd_tZ=XYL7TaSkRN6432SObwH9YS87eLX-h_pMuFYQ@mail.gmail.com>
 <CAOHCbivAK0ypmMhrhJ3zKpF8BHu3h_rUNzeao-HnibJkC-qqGw@mail.gmail.com>
 <ef15483d-5665-4da3-9b79-aefd3c725e1b@isocpp.org>
 <CAOHCbithEUfm+w_06V71=hpkqGUJvqiyDFqD7fesfgLy4uUieg@mail.gmail.com>
 <2c2b9360-8e5e-422d-9b85-124bd947b004@isocpp.org>
 <123b9f65-12fd-4285-bb6c-cfee383d4552@isocpp.org>
 <CAHOE3yeF6KBBz7a1uw58oA3Shh_w0HFGiLtUGEd4ntJAKBauew@mail.gmail.com>
 <CAA7U3HNDqV-j9wU0fw9kBwkoD6TiSmuZZhx1JCg3CNztYVMqqA@mail.gmail.com>
 <CAHOE3yfsCHFTgcgSt+ytzqx_V5GRWrbobO5hSrd8nDQZ2NC98A@mail.gmail.com>
 <CAA7U3HMOQm09UYKJWCQmo34=su7LKeQyYu=2_P401CXSEE0k0A@mail.gmail.com>
 <CAHOE3yd5zt91JmmeAZyLiXxQLUNGQqatX5JRRGGbZVMg-0ckEQ@mail.gmail.com>
 <CAA7U3HNSp1MNvPzcD=9ssb0KSvrutWW2=jHQJknz2FhV4+bcww@mail.gmail.com>
 <CAHOE3ycx4fk=7S0PNcJ0tJsf_pN6ER2YZbF+E8t9n-wvxAGtsQ@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_1570_33137816.1359454682676"
X-Trace: ger.gmane.org 1359454684 31764 80.91.229.3 (29 Jan 2013 10:18:04 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 29 Jan 2013 10:18:04 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCMN7NOYVQEBBXGDT2EAKGQENJEMHYQ@isocpp.org Tue Jan 29 11:18:24 2013
Return-path: <std-proposals+bncBCMN7NOYVQEBBXGDT2EAKGQENJEMHYQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qa0-f72.google.com ([209.85.216.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCMN7NOYVQEBBXGDT2EAKGQENJEMHYQ@isocpp.org>)
	id 1U08Gm-0007hh-6l
	for gclcip-std-proposals@m.gmane.org; Tue, 29 Jan 2013 11:18:24 +0100
Original-Received: by mail-qa0-f72.google.com with SMTP id l8sf619208qaq.7
        for <gclcip-std-proposals@m.gmane.org>; Tue, 29 Jan 2013 02:18:05 -0800 (PST)
X-Received: by 10.224.72.199 with SMTP id n7mr341045qaj.5.1359454685419;
        Tue, 29 Jan 2013 02:18:05 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.119.3 with SMTP id kq3ls107531qeb.67.gmail; Tue, 29 Jan
 2013 02:18:03 -0800 (PST)
X-Received: by 10.49.12.97 with SMTP id x1mr30215qeb.25.1359454683003;
        Tue, 29 Jan 2013 02:18:03 -0800 (PST)
In-Reply-To: <CAHOE3ycx4fk=7S0PNcJ0tJsf_pN6ER2YZbF+E8t9n-wvxAGtsQ@mail.gmail.com>
X-Original-Sender: vjacquet@flowgroup.fr
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?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:2479
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/2479>

------=_Part_1570_33137816.1359454682676
Content-Type: text/plain; charset=ISO-8859-1

There is 2 ways to represent wether we have a value or not:
- a container with 0 or 1 element
- a pointer, either null or valid.

The both have valid yet incompatible use cases, for instance:
- the container-like representation for 0..1 could be promoted to 0..n 
- the pointer-like representation could be promoted to unique_ptr if the 
size of the object grows to the point where having unused memory space 
would be just a waste.

If it doesn't make sense to have both representations in the same type (and 
I believe it doesn"t), I wouldn't  mind having two types with distinct, 
unambiguous definitions.
I find the current definition of optional somewhat difficult to understand 
as "optional" suggests 0 or 1, while it is defined as "a nullable type T 
that can store in its storage space either a value of type T or a special 
value nullopt". And, btw, if I understand the technical argument about "why 
not nullptr", I do not feel confortable about having a pointer like 
interface not capable to compare to nullptr.

Regards,
Vincent


On Monday, January 28, 2013 9:27:06 PM UTC+1, Daniel James wrote:
>
> On 28 January 2013 20:10, Olaf van der Spek <olafv...@gmail.com<javascript:>> 
> wrote: 
> > On Mon, Jan 28, 2013 at 8:54 PM, Daniel James <dnl...@gmail.com<javascript:>> 
> wrote: 
> >> On 28 January 2013 10:08, Olaf van der Spek <olafv...@gmail.com<javascript:>> 
> wrote: 
> >>> On Mon, Jan 28, 2013 at 10:07 AM, Daniel James <dnl...@gmail.com<javascript:>> 
> wrote: 
> >>>> 
> >>>> It depends on how well the range algorithms works out. They might 
> >>>> provide a more elegant way to manipulate optionals than if 
> statements, 
> >>>> similar to how a range algorithm can be more elegant than a for loop. 
> >>>> This has worked out well in other languages, for example in Scala: 
> >>> 
> >>> Wouldn't this be better handled by a wrapper that allows optionals, 
> >>> (smart) pointers and references to be handled as ranges? 
> >>> Separation of concerns says this shouldn't be handled by optional 
> itself. 
> >> 
> >> Fair enough. I find that such separation of concerns can end up with 
> >> unwieldy interfaces, but that's a matter of opinion. 
> > 
> > We can't add a range interface to raw pointers anyway, right? 
>
> I don't want to add a range interface to raw pointers. 
>

-- 

--- 
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/?hl=en.



------=_Part_1570_33137816.1359454682676
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div>There is 2 ways to represent wether we have a value or not:</div><div>=
- a container with 0 or 1 element</div><div>- a pointer, either null or val=
id.</div><br>The both have valid yet incompatible use cases, for instance:<=
div>- the container-like representation for 0..1 could be promoted to 0..n&=
nbsp;</div><div>- the pointer-like representation could be promoted to uniq=
ue_ptr if the size of the object grows to the point where having unused mem=
ory space would be just a waste.<br></div><div><br></div><div>If it doesn't=
 make sense to have both representations in the same type (and I believe it=
 doesn"t), I wouldn't &nbsp;mind having two types with distinct, unambiguou=
s definitions.</div><div>I find the current definition of optional somewhat=
 difficult to understand as "optional" suggests 0 or 1, while it is defined=
 as "a nullable type T that can store in its storage space either a value o=
f type T or a special value nullopt". And, btw, if I understand the technic=
al argument about "why not nullptr", I do not feel confortable about having=
 a pointer like interface not capable to compare to nullptr.</div><div><br>=
</div><div>Regards,</div><div>Vincent</div><div><br><br>On Monday, January =
28, 2013 9:27:06 PM UTC+1, Daniel James wrote:<blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padd=
ing-left: 1ex;">On 28 January 2013 20:10, Olaf van der Spek &lt;<a href=3D"=
javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"W7K3ykDCr4IJ">olafv=
....@gmail.com</a>&gt; wrote:
<br>&gt; On Mon, Jan 28, 2013 at 8:54 PM, Daniel James &lt;<a href=3D"javas=
cript:" target=3D"_blank" gdf-obfuscated-mailto=3D"W7K3ykDCr4IJ">dnl...@gma=
il.com</a>&gt; wrote:
<br>&gt;&gt; On 28 January 2013 10:08, Olaf van der Spek &lt;<a href=3D"jav=
ascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"W7K3ykDCr4IJ">olafv...=
@gmail.com</a>&gt; wrote:
<br>&gt;&gt;&gt; On Mon, Jan 28, 2013 at 10:07 AM, Daniel James &lt;<a href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"W7K3ykDCr4IJ">d=
nl...@gmail.com</a>&gt; wrote:
<br>&gt;&gt;&gt;&gt;
<br>&gt;&gt;&gt;&gt; It depends on how well the range algorithms works out.=
 They might
<br>&gt;&gt;&gt;&gt; provide a more elegant way to manipulate optionals tha=
n if statements,
<br>&gt;&gt;&gt;&gt; similar to how a range algorithm can be more elegant t=
han a for loop.
<br>&gt;&gt;&gt;&gt; This has worked out well in other languages, for examp=
le in Scala:
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; Wouldn't this be better handled by a wrapper that allows o=
ptionals,
<br>&gt;&gt;&gt; (smart) pointers and references to be handled as ranges?
<br>&gt;&gt;&gt; Separation of concerns says this shouldn't be handled by o=
ptional itself.
<br>&gt;&gt;
<br>&gt;&gt; Fair enough. I find that such separation of concerns can end u=
p with
<br>&gt;&gt; unwieldy interfaces, but that's a matter of opinion.
<br>&gt;
<br>&gt; We can't add a range interface to raw pointers anyway, right?
<br>
<br>I don't want to add a range interface to raw pointers.
<br></blockquote></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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_1570_33137816.1359454682676--

.
