Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53105 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26399 invoked from network); 6 Jun 2011 23:12:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2011 23:12:06 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 207.97.245.113 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 207.97.245.113 smtp113.iad.emailsrvr.com Linux 2.6 Received: from [207.97.245.113] ([207.97.245.113:46221] helo=smtp113.iad.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 07/51-20040-5CE5DED4 for ; Mon, 06 Jun 2011 19:12:06 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp41.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 52395290465; Mon, 6 Jun 2011 19:02:16 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp41.relay.iad1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id C7A63290429; Mon, 6 Jun 2011 19:02:15 -0400 (EDT) Message-ID: <4DED5C77.8040209@sugarcrm.com> Date: Mon, 06 Jun 2011 16:02:15 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: Matthew Weier O'Phinney CC: "internals@lists.php.net" References: <4DED3A29.1090209@sugarcrm.com> <4DED43D4.4070006@sugarcrm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Callable typehint From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > The point, though, is that with such a typehint available, we can reduce > boilerplate code like the following: Sure. How about reducing boilterplate code like this: if(is_readable($foo)) { $var = file_get_contents($foo); } else { throw InvalidArgumentException(); } Why won't we make language construct to do that too? I don't think these things belong in the language syntax. > > public function addCallback($callback) > { > if (!is_callback($callback)) { > throw new InvalidArgumentException(); > } > > The typehint makes this simpler: > > public function addCallback(callback $callback) > You understand that these two pieces of code are completely different - for one, you can't catch failing strict type check upstream of addCallback and recover. > which allows us to rely on PHP's native error handling. I, for one, > would love to see this. I wouldn't love it a bit, frankly, as "rely on PHP's native error handling" in this context means "bombing out in runtime without any idea what went wrong". When you have exception, you could make it print what happened and recover, if you want. When you have fatal error, you can't do much at all. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227