220 2160 <CAGsORuDocQnk192nhjxQ9_9zAoRiw8KbCnREuu6LOuvHMjVQdw@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Zhihao Yuan <lichray@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: optional<T>, one more value or two states
Date: Thu, 24 Jan 2013 13:17:55 -0600
Lines: 55
Approved: news@gmane.org
Message-ID: <CAGsORuDocQnk192nhjxQ9_9zAoRiw8KbCnREuu6LOuvHMjVQdw@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>
	<51013FC6.9080907@bubblescope.net>
	<CAGsORuDaFt3tweHJGe+XeWLjoMnCUc+r8-3uLR9JJVFYOmW3BA@mail.gmail.com>
	<CANh-dXkCNy5iVk3D0NZxRw9DifzZwou2KFi+r374cBV5fFRXFQ@mail.gmail.com>
	<CAGsORuB4mQ-+xb3R79=kKEnoLfQgbY2ZRuD6A-a8V5+nndUWtw@mail.gmail.com>
	<CANh-dXnF6yCyYWwwA0DGbot5EBufUkQqoz8sy-hRqHN-JmGeiA@mail.gmail.com>
	<CAGsORuBVbM8gMvfvko7aJYX62eRh=Snoq1AU2L4GvfoGnZWeCg@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 1359055076 18643 80.91.229.3 (24 Jan 2013 19:17:56 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 24 Jan 2013 19:17:56 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCUILMGRQMARBZERQ2EAKGQE3AHMY6I@isocpp.org Thu Jan 24 20:18:15 2013
Return-path: <std-proposals+bncBCUILMGRQMARBZERQ2EAKGQE3AHMY6I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ea0-f197.google.com ([209.85.215.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCUILMGRQMARBZERQ2EAKGQE3AHMY6I@isocpp.org>)
	id 1TySJS-0007Os-7P
	for gclcip-std-proposals@m.gmane.org; Thu, 24 Jan 2013 20:18:14 +0100
Original-Received: by mail-ea0-f197.google.com with SMTP id j13sf10644322eaa.8
        for <gclcip-std-proposals@m.gmane.org>; Thu, 24 Jan 2013 11:17:56 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.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=B9eIEXm89du358R2ceIc7BAtAB8xRvydJUuyXG4lU2I=;
        b=PeBmz8+aNzggKzNc2cgrZ2DA9OEBrljImcZ8yq+fNsBRFlzyg9tmbN3XlsJkJVg7yc
         2RAxrgbBS5i4GEZovVa9l350ZJkoatTJNFGxXN/0ffyJyy/L/LtQEeryztuMf00QgSi8
         mnSP5t4eFzjY1bn7LYbVVASqNNDFshIk5sCwfclleUhD6TdxlWsVm1YizYwSXO/aDXIT
         9CR4/nJA/t3sM6rJ8+W4wJRuwq0AzNOmIIxNPAwH0iOQgvuBb3nyGKoAtV7/d+1qWPhu
         ITeMXi17+wJAcnltsNICOOQrVggqjL4lHyo8MVVMc+J2fHLrC 
X-Received: by 10.152.46.212 with SMTP id x20mr947913lam.10.1359055076744;
        Thu, 24 Jan 2013 11:17:56 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.129.195 with SMTP id ny3ls49662lab.34.gmail; Thu, 24 Jan
 2013 11:17:56 -0800 (PST)
X-Received: by 10.112.9.37 with SMTP id w5mr1233951lba.62.1359055076170;
        Thu, 24 Jan 2013 11:17:56 -0800 (PST)
X-Received: by 10.112.9.37 with SMTP id w5mr1233949lba.62.1359055076144;
        Thu, 24 Jan 2013 11:17:56 -0800 (PST)
Original-Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182])
        by mx.google.com with ESMTPS id k8si11014552lbl.286.2013.01.24.11.17.56
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 24 Jan 2013 11:17:56 -0800 (PST)
Received-SPF: pass (google.com: domain of lichray@gmail.com designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182;
Original-Received: by mail-lb0-f182.google.com with SMTP id gg6so7229130lbb.27
        for <std-proposals@isocpp.org>; Thu, 24 Jan 2013 11:17:56 -0800 (PST)
X-Received: by 10.152.46.17 with SMTP id r17mr2857737lam.47.1359055075939;
 Thu, 24 Jan 2013 11:17:55 -0800 (PST)
Original-Received: by 10.112.75.131 with HTTP; Thu, 24 Jan 2013 11:17:55 -0800 (PST)
In-Reply-To: <CAGsORuBVbM8gMvfvko7aJYX62eRh=Snoq1AU2L4GvfoGnZWeCg@mail.gmail.com>
X-Original-Sender: lichray@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of lichray@gmail.com designates 209.85.217.182 as permitted sender)
 smtp.mail=lichray@gmail.com;       dkim=pass header.i=@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?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:2160
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/2160>

On Thu, Jan 24, 2013 at 12:35 PM, Zhihao Yuan <lichray@gmail.com> wrote:
>> Which functional languages have user-defined implicit conversions at all?
>
> Scala.

Besides, let me say a few words about implicit conversion.
An implicit conversion from T to U should ensure that T is-a
U, the possible values of T is a subset of the possible values
of U, T -> U holds a partial-order relation.

And you will see any implicit conversion violating the above
statements is a flaw.

Narrowing conversion.  Int type T can be converted to int type
U even if T has a larger range.  One of the criticism of C++'s
type safety.

char const* to std::string.  Pointer is not a collection of chars,
while std::string is.  So `string(strdup("aha"))` result in a memory
leak.  And such a conversion implies the `array to pointer`
conversion, which makes  "nu\0\l" lost everything after '\0'.

"Those are C's probem/C has NUL-terminated strings from the
stone age. "  OK.  I'm not trying to argue these.  But keep this
in mind:  an implicit conversion from T to U without T <= U
is a flaw.

Let's go back to `std::optional`.  So that's why I ask, what is
optional<T>.  A T with a larger range, or a T with two states.
If (1), then an implicit conversion is OK, but I suggest that
to ensure "undefined == undefined" (JavaScript), or
"None == None" (Python).  Although I don't like it, and I don't
think it's safe, but this is *the* extended value.

If optional<T> is a T with two states, things go easy.  We have
numerous successful use cases in the functional programming
area.


--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://4bsd.biz/

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To post to this group, send email to std-proposals@isocpp.org.
To unsubscribe from this group, send email to std-proposals+unsubscribe@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



.
