220 26561 <4ac3803f-a87d-4551-947f-43f106bdda20@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: auto type deduction for *_cast return argument
Date: Tue, 5 Jul 2016 08:07:31 -0700 (PDT)
Lines: 80
Approved: news@gmane.org
Message-ID: <4ac3803f-a87d-4551-947f-43f106bdda20@isocpp.org>
References: <58140e46-2adc-4eac-8f51-72d3685cdf0b@isocpp.org>
 <7E3409C2-A2AC-4562-BB06-6D5D5ACE8AC8@gmail.com>
 <00caca39-d36a-475c-840f-79759e99265d@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_367_161175421.1467731251596"
X-Trace: ger.gmane.org 1467731257 2562 80.91.229.3 (5 Jul 2016 15:07:37 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 5 Jul 2016 15:07:37 +0000 (UTC)
Cc: xavinaar@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBNE2565QKGQEAIIIA6A@isocpp.org Tue Jul 05 17:07:35 2016
Return-path: <std-proposals+bncBCEKFTV6ZUMBBNE2565QKGQEAIIIA6A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f197.google.com ([209.85.214.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBNE2565QKGQEAIIIA6A@isocpp.org>)
	id 1bKRwk-0002Rt-J7
	for gclcip-std-proposals@m.gmane.org; Tue, 05 Jul 2016 17:07:34 +0200
Original-Received: by mail-ob0-f197.google.com with SMTP id da8sf213092740obb.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 05 Jul 2016 08:07:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=rWbXZjhrlQhNyxX8qVB41klwYnMtwNTpqVqTwOetRNs=;
        b=UozrCyzFC8kMdlCr9oyax0jD9Z21GqjCBf2VdtGTuxms6XbN4GvoxSq33iLJ3L+1uC
         0wukAPx5FHABZHU4NtBcofwZDlCeSrLFCzg66T3MQTwCqt86PqUse3lB1+yyFHmIt09w
         BltZQIiotpiloGdBUb5UjVEB7JVL0lIcaudQmzG9mgnHlYOxWjzixH6eO4EVI1WCJfwH
         fP+4D1q+ND8II8y4sGhZlNoPn+Kv624joWcK4vFei7NhhdG/2qJMJUSg5IiRp7oZwYzm
         x4D42dhz/IcMLFaK9f9XgaqLDv7L4S6V5+Fxc3hwQYi17o3idKiYNP7KatF4AE8uwysM
         yCqw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=rWbXZjhrlQhNyxX8qVB41klwYnMtwNTpqVqTwOetRNs=;
        b=ae/TPzdeijYpUvwp7UEsWqwhuUkurBl92w2I4h6qZYlOnO3RxqA2IK09EimnCHkMKB
         fWEKwXOnwJj/kvSebMbk+6nNv4bf0x+isfq2OSYZnfVMzcsHAnQIU36L3xybXVGNFv9V
         q+yJ9ylMBGVisrdrpCCPyTmkE/fOHPaRFUJ37u94DuN7aAjQV7LjvbaERiz9teRn3aJ0
         iA8MWM4dYdl56l0FVkdBWrzdzJ6euzr6Dl1crC9So7JQYSSEww2530AZuau21rsfHqXg
         4BwkLyIttqwRGZxOrL9VhibO75JaS/xeBHSkxDOUNrDwitzFp4BEfIiMYo4HqdeuZMGX
         ZTVQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=rWbXZjhrlQhNyxX8qVB41klwYnMtwNTpqVqTwOetRNs=;
        b=RJmhFC3m+niVVFexfLywcwaDmo/Ha4p4HfSBw1n2q++1VAMCdd0QGkQ09RJ51FX9fA
         skW0TiCOrqi/3utQ0rfH4MbFlu0NWhrpXWmmE4nhiuTqMsZn0qBOpHPIJ8/10EhHJz+g
         6MfLyn9a75FH1LI6zMemUlsWw66n97dHGQTXvkC4pkPrT4taKaAfHrDJlzUjS5yKHyW7
         J7hlEZeaeq4jhYyI8bFcFnLxfDudzKHq0o2WMnvpkAsmk1zWzn5vqAi3jbNYL4F71Mdr
         KWRT4sCpsybS+/Yy7TrHDS8IScHF8Z0SwhzmbRmSvjYZIKv4px7SRAQfyQUh9cnUeu3q
         /+iA==
X-Gm-Message-State: ALyK8tJIex18cE/QE+YZihz36+usHBvN9yhSp3KLcuDilAcnSgk7sSO9eMAckVE3Aqs/Zw==
X-Received: by 10.36.146.5 with SMTP id l5mr17703879itd.0.1467731253530;
        Tue, 05 Jul 2016 08:07:33 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.133.31 with SMTP id h31ls1930789iod.38.gmail; Tue, 05 Jul
 2016 08:07:32 -0700 (PDT)
X-Received: by 10.36.17.15 with SMTP id 15mr429070itf.10.1467731252494;
        Tue, 05 Jul 2016 08:07:32 -0700 (PDT)
In-Reply-To: <00caca39-d36a-475c-840f-79759e99265d@isocpp.org>
X-Original-Sender: jmckesson@gmail.com
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: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:26561
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/26561>

------=_Part_367_161175421.1467731251596
Content-Type: multipart/alternative; 
	boundary="----=_Part_368_848721670.1467731251596"

------=_Part_368_848721670.1467731251596
Content-Type: text/plain; charset=UTF-8

On Tuesday, July 5, 2016 at 4:18:44 AM UTC-4, xavi...@gmail.com wrote:
>
> On countrary: passing *dynamic_cast* to function always means you want to 
> cast to function argument type.
>

*Which* function's argument type? By foisting deduction on the function, 
you basically make overloading impossible for that particular argument.

Additionally, you've forgotten something very important about 
`dynamic_cast`: *it can fail*.

If `f` takes a pointer, does it expect to get a nullptr for that parameter? 
If `f` takes a reference, does the code calling `f` expect to get a 
`std::bad_cast` exception? Will throwing such an exception break other 
expressions being evaluated to call `f`?

Indeed, this is a good reason to *not* make such casts easier to type. If 
you're using casts so frequently that you need a language change to avoid 
lots of repetition, then I'd say that your code is doing something wrong.

Explicit casting should be sufficiently exceptional in your codebase that 
if it takes a few extra keystrokes, you can live with it.

-- 
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4ac3803f-a87d-4551-947f-43f106bdda20%40isocpp.org.

------=_Part_368_848721670.1467731251596
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, July 5, 2016 at 4:18:44 AM UTC-4, xavi...@gmai=
l.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">O=
n countrary: passing <b>dynamic_cast</b> to function always means you want =
to cast to function argument type.<br></div></blockquote><div><br><i>Which<=
/i> function&#39;s argument type? By foisting deduction on the function, yo=
u basically make overloading impossible for that particular argument.<br><b=
r>Additionally, you&#39;ve forgotten something very important about `dynami=
c_cast`: <i>it can fail</i>.<br><br>If `f` takes a pointer, does it expect =
to get a nullptr for that parameter? If `f` takes a reference, does the cod=
e calling `f` expect to get a `std::bad_cast` exception? Will throwing such=
 an exception break other expressions being evaluated to call `f`?<br><br>I=
ndeed, this is a good reason to <i>not</i> make such casts easier to type. =
If you&#39;re using casts so frequently that you need a language change to =
avoid lots of repetition, then I&#39;d say that your code is doing somethin=
g wrong.<br><br>Explicit casting should be sufficiently exceptional in your=
 codebase that if it takes a few extra keystrokes, you can live with it.<br=
></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/4ac3803f-a87d-4551-947f-43f106bdda20%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4ac3803f-a87d-4551-947f-43f106bdda20=
%40isocpp.org</a>.<br />

------=_Part_368_848721670.1467731251596--

------=_Part_367_161175421.1467731251596--

.
