Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53115 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61562 invoked from network); 7 Jun 2011 02:50:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jun 2011 02:50:50 -0000 Authentication-Results: pb1.pair.com header.from=martinscotta@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=martinscotta@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: martinscotta@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:57342] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6F/87-20040-8029DED4 for ; Mon, 06 Jun 2011 22:50:49 -0400 Received: by vwl1 with SMTP id 1so3714552vwl.29 for ; Mon, 06 Jun 2011 19:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=CSXm0/a4ETywiByMcDSQi/TLmksq+VsgFv7W2ew/lp0=; b=glppXwyTs3jTDF4APJ3eDvAvq2XGC/tsNuMfGnyGbaNMs6g3DujaUgQsor939oi5aA 1JGB2Lvjdeab14wH7CJUotsMFY9ZTECwhziUH88KSjZjSV0QoYvG0OVlZqppRKdc9w/e bhLX4u3JmDqWPuviECzNPBZBHoGlq9zPRdYj8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=HKzQ25x5c3YiJSTynF7KukJzW03XniMIjPPxw4HWkRljm+EwKqUMvHlrMP/SOkravp 6Ek+5s7EnHvqEyBEeMkvSmHg6N/Yddl/dDgBzCMyygs6UpjF39Mafs73rx1zaJd6HVKu VrNnrOD/NeZjElDl3orYaXRJ5gixxm4KsNWEo= MIME-Version: 1.0 Received: by 10.220.199.73 with SMTP id er9mr720777vcb.83.1307415044900; Mon, 06 Jun 2011 19:50:44 -0700 (PDT) Received: by 10.220.192.129 with HTTP; Mon, 6 Jun 2011 19:50:44 -0700 (PDT) In-Reply-To: <4DED5C77.8040209@sugarcrm.com> References: <4DED3A29.1090209@sugarcrm.com> <4DED43D4.4070006@sugarcrm.com> <4DED5C77.8040209@sugarcrm.com> Date: Mon, 6 Jun 2011 23:50:44 -0300 Message-ID: To: Stas Malyshev Cc: "Matthew Weier O'Phinney" , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=90e6ba53b07053494804a5164950 Subject: Re: [PHP-DEV] Callable typehint From: martinscotta@gmail.com (Martin Scotta) --90e6ba53b07053494804a5164950 Content-Type: text/plain; charset=ISO-8859-1 Martin Scotta On Mon, Jun 6, 2011 at 8:02 PM, Stas Malyshev wrote: > 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(); > } > trol? > > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --90e6ba53b07053494804a5164950--