220 2223 <CALJmx61-4473v7ACaVbuLwmsvFvqDp=xDG1RmtE0+0rLPOa6vw@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Dean Michael Berris <dberris@google.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: optional<T>, one more value or two states
Date: Fri, 25 Jan 2013 16:07:32 +1100
Lines: 53
Approved: news@gmane.org
Message-ID: <CALJmx61-4473v7ACaVbuLwmsvFvqDp=xDG1RmtE0+0rLPOa6vw@mail.gmail.com>
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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: ger.gmane.org 1359090453 9509 80.91.229.3 (25 Jan 2013 05:07:33 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 25 Jan 2013 05:07:33 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCD3FSEO4IDBBFNGRCEAKGQEERCINXQ@isocpp.org Fri Jan 25 06:07:52 2013
Return-path: <std-proposals+bncBCD3FSEO4IDBBFNGRCEAKGQEERCINXQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ia0-f199.google.com ([209.85.210.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCD3FSEO4IDBBFNGRCEAKGQEERCINXQ@isocpp.org>)
	id 1TybW3-0007dG-Sh
	for gclcip-std-proposals@m.gmane.org; Fri, 25 Jan 2013 06:07:52 +0100
Original-Received: by mail-ia0-f199.google.com with SMTP id u20sf17771761iag.10
        for <gclcip-std-proposals@m.gmane.org>; Thu, 24 Jan 2013 21:07:34 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=x-received:x-beenthere:x-received:x-received:received-spf
         :mime-version:x-received:in-reply-to:references:date:message-id
         :subject:from:to:x-original-sender:x-original-authentication-results
         :reply-to:precedence:mailing-list:list-id:x-google-group-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=PEYMdO3Yl2UUJsQQqwvo4T58Omz4EtdJzWtZQ4yEtcE=;
        b=Z1/tx/y7Ofoa4KK1AOdU2GAQJbFkJIRCcajYA2iEcaTQc04CKPB7LB2Oj0mpiiMnuc
         GR2AzmqeGpyXNXylyiO+7mkXW2QZyBLBfVXLxCK5uAn25q1So/P7045UO5v7zGBUbrci
         RFFxa/Z5xMpm2peZVz1QpTIEYBubrToZCMT7aZm37ik/tuxoclEGOnarAdB7MTs4PiSt
         H/cOB6SQi3By8tLj3AlA5YIylm2E0hEBL5O7dPylLydrKtAevE+QHuo4k3Oq+C/Un0f3
         1fThkL5PMFnT3Yt48TzduXnBSffjwLmVmiIXHZ7UGjfLgfUN 
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=x-received:x-beenthere:x-received:x-received:received-spf
         :mime-version:x-received:in-reply-to:references:date:message-id
         :subject:from:to:x-gm-message-state:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-google-group-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=PEYMdO3Yl2UUJsQQqwvo4T58Omz4EtdJzWtZQ4yEtcE=;
        b=MEzDklJsVq6w9HQaySJ0CbH3gAaRneoCVZfpIVAVmgfT+t9GooY5TeRmxkdKs2SedH
         kmb8HfG6h7xida1Of4t87EwLW6ekrknxgsKZoWLBFGZtbtpGYBsaXUXlfiKs1PgldFsG
         RdSMmTNh10G2sFphPGfSBe90UnqXtwmyJBZGz6zUCbdm1Nz2RCoDwUeBV7qjz5r/JOkX
         RrdBzyrml96bf7qlG8rACe5XKyx+Eb5crv/HvGahvGd7SUYWSOwqk0OCYlEEzPTZLyAt
         t84BRDP7hNfQ1SUjDA5R 
X-Received: by 10.42.212.209 with SMTP id gt17mr2882354icb.31.1359090453792;
        Thu, 24 Jan 2013 21:07:33 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.10.228 with SMTP id l4ls139039igb.24.canary; Thu, 24 Jan
 2013 21:07:33 -0800 (PST)
X-Received: by 10.50.158.170 with SMTP id wv10mr3216676igb.75.1359090452931;
        Thu, 24 Jan 2013 21:07:32 -0800 (PST)
X-Received: by 10.50.158.170 with SMTP id wv10mr3216675igb.75.1359090452917;
        Thu, 24 Jan 2013 21:07:32 -0800 (PST)
Original-Received: from mail-ia0-x233.google.com (ia-in-x0233.1e100.net [2607:f8b0:4001:c02::233])
        by mx.google.com with ESMTPS id dx3si3558538igc.19.2013.01.24.21.07.32
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 24 Jan 2013 21:07:32 -0800 (PST)
Received-SPF: pass (google.com: domain of dberris@google.com designates 2607:f8b0:4001:c02::233 as permitted sender) client-ip=2607:f8b0:4001:c02::233;
Original-Received: by mail-ia0-f179.google.com with SMTP id x24so6027622iak.38
        for <std-proposals@isocpp.org>; Thu, 24 Jan 2013 21:07:32 -0800 (PST)
X-Received: by 10.50.222.228 with SMTP id qp4mr3222184igc.87.1359090452750;
 Thu, 24 Jan 2013 21:07:32 -0800 (PST)
Original-Received: by 10.231.132.65 with HTTP; Thu, 24 Jan 2013 21:07:32 -0800 (PST)
In-Reply-To: <CAOHCbivAK0ypmMhrhJ3zKpF8BHu3h_rUNzeao-HnibJkC-qqGw@mail.gmail.com>
X-Gm-Message-State: ALoCoQkix/muQwfRY73NZGDZD2pv6Tlv7AjBph9hQLZi1PXzQC5TfqQIPE4+ukoiHT8c5ZvUW2cNVAheS4BsVlns2VkST8Q7fu6WIS5PkqoWWteL6AstwnpDxrDf7q4aCKB6CAL3FTO3MxSSEQvD6m49f769MN+AO4VnmYujAFV/dJJfHMK4xyNlnGOT/zTsMZIcXH5tO2ft
X-Original-Sender: dberris@google.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of dberris@google.com designates 2607:f8b0:4001:c02::233 as permitted
 sender) smtp.mail=dberris@google.com;       dkim=pass header.i=@google.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?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:2223
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/2223>

On Fri, Jan 25, 2013 at 3:56 PM, Tony V E <tvaneerd@gmail.com> wrote:
> On Thu, Jan 24, 2013 at 7:10 PM, Dean Michael Berris <dberris@google.com> wrote:
>>
>> In my opinion:
>>
>> - There's a precedent in other languages for a ".get(default_value)".
>> Why don't we have this for optional instead?
>>
>
> opt.get(17) doesn't look like it is using a default to me.  Typically
> get(17) is get the 17th element or lookup with key = 17, etc.
>

Right. I was confused by Python's dict that has a method "get" which
takes the key and the default value to return if the key is not found.

>
>> - Why are we forcing pointer semantics on optional? Maybe there's a
>> different concept here at play.
>>
>
> Because much of optional's interface is similar to pointers:  you
> access the value with *opt and opt can be NULL.
>

Right, but that's a good thing right? Something you can copy around,
acts as a value, and gives you pointer semantics. It could be that the
answer is a standalone function that works with pointers, optionals,
and NullableProxy objects like:

template <class T, class NullableProxy>
T get(NullableProxy &&p, T&& t) {
  if (p) return *p;
  return std::forward<T>(t);
}

> That is the essential "problem" with optional.  Sometimes it acts
> value-ish, sometimes pointer-ish.  It is like quantum physics -
> sometimes a particle, sometimes a wave...
>

I thought it was always a value. Is there any confusion in that?

-- 

--- 
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.



.
