220 9244 <ldauqr$63v$1@ger.gmane.org> article
Path: news.gmane.org!not-for-mail
From: Matthew Woehlke <mw_triad@users.sourceforge.net>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: add "implicit" keyword?
Date: Mon, 10 Feb 2014 11:30:32 -0500
Lines: 67
Approved: news@gmane.org
Message-ID: <ldauqr$63v$1@ger.gmane.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
X-Trace: ger.gmane.org 1392049837 6471 80.91.229.3 (10 Feb 2014 16:30:37 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 10 Feb 2014 16:30:37 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCO5FYHBU4ERBM754OLQKGQEEHGSLYY@isocpp.org Mon Feb 10 17:30:45 2014
Return-path: <std-proposals+bncBCO5FYHBU4ERBM754OLQKGQEEHGSLYY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-la0-f72.google.com ([209.85.215.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCO5FYHBU4ERBM754OLQKGQEEHGSLYY@isocpp.org>)
	id 1WCtkq-0005zJ-8y
	for gclcip-std-proposals@m.gmane.org; Mon, 10 Feb 2014 17:30:44 +0100
Original-Received: by mail-la0-f72.google.com with SMTP id pv20sf10255750lab.11
        for <gclcip-std-proposals@m.gmane.org>; Mon, 10 Feb 2014 08:30:43 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:to:from:subject:date:lines:message-id
         :mime-version:user-agent:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=nmbD3HsrEARkKNb3lw/+ExyI/fUjdATLHBU5VIsuaas=;
        b=Qf2uUjNj44tZxUpMpMqAFg9D0/LxmL99BMuzdY5lwydVWw6uY3sf4RBohJb3BuLlV2
         OVDNnIZRuUvvkor4hQwPa1vl6lOtFO2WwpmRd7e1qieuJLKFfNavGezY1HV4/N6DryOM
         40PWbe4zeMJ7HpOyKAv6y7PmSaRgJAKxAZUPc+4Hv1HUSQ2TKxjsxc3veH8Rnmut4Ns2
         JV7Gk3cK5ufDQja5WX6NikHksErYFC0fCzYuUu1yR1L508V4Ay9J2qodJRm2/e2sTL55
         LjBGUhYxm8DpKvQG3OD4fqpVeekt96OQ2IS1VKP89vohQXrGeSvypuu5iRDnWmcL5yTo
         zjJA==
X-Gm-Message-State: ALoCoQng9wjhogESjvrHxK0XgEcu7jvkE+li8H3S88BpCqXo88SCNrxb7MRqti9erhi8oE75FZTE
X-Received: by 10.152.43.194 with SMTP id y2mr13668190lal.0.1392049843770;
        Mon, 10 Feb 2014 08:30:43 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.27.199 with SMTP id v7ls107685lag.59.gmail; Mon, 10 Feb
 2014 08:30:42 -0800 (PST)
X-Received: by 10.112.99.74 with SMTP id eo10mr21421802lbb.15.1392049842758;
        Mon, 10 Feb 2014 08:30:42 -0800 (PST)
Original-Received: from plane.gmane.org (plane.gmane.org. [80.91.229.3])
        by mx.google.com with ESMTPS id t10si8324922lat.27.2014.02.10.08.30.42
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Mon, 10 Feb 2014 08:30:42 -0800 (PST)
Received-SPF: pass (google.com: domain of gclcip-std-proposals@m.gmane.org designates 80.91.229.3 as permitted sender) client-ip=80.91.229.3;
Original-Received: from list by plane.gmane.org with local (Exim 4.69)
	(envelope-from <gclcip-std-proposals@m.gmane.org>)
	id 1WCtkn-0005yV-Uv
	for std-proposals@isocpp.org; Mon, 10 Feb 2014 17:30:41 +0100
Original-Received: from tripoint.kitware.com ([66.194.253.20])
        by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <std-proposals@isocpp.org>; Mon, 10 Feb 2014 17:30:41 +0100
Original-Received: from mw_triad by tripoint.kitware.com with local (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <std-proposals@isocpp.org>; Mon, 10 Feb 2014 17:30:41 +0100
X-Injected-Via-Gmane: http://gmane.org/
Original-Lines: 58
Original-X-Complaints-To: usenet@ger.gmane.org
X-Gmane-NNTP-Posting-Host: tripoint.kitware.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
X-Original-Sender: mw_triad@users.sourceforge.net
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of gclcip-std-proposals@m.gmane.org designates 80.91.229.3 as
 permitted sender) smtp.mail=gclcip-std-proposals@m.gmane.org
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:9244
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/9244>

Objective:
----------
Create a new keyword "implicit", having the meaning 'not "explicit"'. 
That is, this keyword would annotate that a constructor or conversion 
operator is allowed to be called in a manner that would be denied by 
'explicit'.

Rationale:
----------
"explicit" is a great tool for avoiding mistakes in the use of a class. 
Unfortunately, programmers must remember to use it, and there is not 
presently a mechanism to diagnose failure to do so. Adding an "implicit" 
keyword would permit compilers to diagnose constructors and/or 
conversion operators which are in fact implicit according to the 
standard, but are not marked as such. This would provide a mechanism to 
warn programmers that a constructor or conversion operator is 
potentially dangerous, while allowing them to clearly specify when this 
is the intent.

Considerations:
---------------
Since keywords are scarce and the introduction of new keywords carries 
the potential to break existing code, I suggest to make "implicit" a 
context sensitive keyword in a similar manner as e.g. "override":

- If the compiler encounters the "implicit" token within a class 
definition scope, it shall perform a forward scan of following tokens. 
If the following token is the class name or equivalent (e.g. if we get 
'auto' to declare constructors), or is followed by "operator" and then a 
type name, "implicit" shall be treated as a keyword with the above meaning.

- For all other cases, "implicit" shall be treated as a potential type 
name or identifier (i.e. historic behavior, not a keyword).

Alternatives:
-------------
Rather than a keyword, an attribute "[[implicit]]" could be used for 
this purpose. Projects that prefer the appearance of a keyword can 
define a macro "implicit" that expands to this attribute for supporting 
compilers, or empty otherwise.

Addendum:
---------
The behavior of a constructor or conversion operator that is not 
specified "explicit" remains "implicit" (i.e. this would not change the 
meaning of existing code).

References:
-----------
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60135

-----------------------------------------------------------------------

What do folks think? Is this a reasonable wish? Is there a better way to 
achieve this goal?

-- 
Matthew

-- 

--- 
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/.

.
