Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61175 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20476 invoked from network); 12 Jul 2012 17:12:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jul 2012 17:12:42 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.160.170 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.160.170 mail-gh0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:47502] helo=mail-gh0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/C1-11045-A850FFF4 for ; Thu, 12 Jul 2012 13:12:42 -0400 Received: by ghbg2 with SMTP id g2so3128359ghb.29 for ; Thu, 12 Jul 2012 10:12:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding:x-gm-message-state; bh=M1AwwxbbxFh45KLizd7nhIadsmb/6ZYXv7pmd6vTtAM=; b=knwztT5HbYZ7AqLpYwKnjjPt1+n2/rnMT1wU8yGNBjjc+7HA1vwqgbCa0jnwKZFPFS EUVFmqX1m+I6Hyk4upSbXSITWPC567s5WwjJOzi1ZJWJMa2ilrBnWPeC47U/U2srovIv /xsltda14HFs7L7ASHbqKGhpI5Pvo4kdHW0I+0oh5LoFYvWgiq64BvY/6bsHZWCxt2q5 n/ssEKVosFy71TewzvftJGzy5VuOJ43M5CRbvaaQQ0kwW68fb9LBinSbE0Qf1auUfymT 16AMxF0RAGwu0FAexv2uw5z1W6y5t9kVLht6UpaaZVQl3535XUWF4O8XqKudSfV3168R /W1g== Received: by 10.101.218.19 with SMTP id v19mr18590032anq.63.1342113159614; Thu, 12 Jul 2012 10:12:39 -0700 (PDT) Received: from [172.16.26.30] ([38.106.64.245]) by mx.google.com with ESMTPS id w61sm9785039yhi.5.2012.07.12.10.12.37 (version=SSLv3 cipher=OTHER); Thu, 12 Jul 2012 10:12:38 -0700 (PDT) Message-ID: <4FFF0584.6080708@lerdorf.com> Date: Thu, 12 Jul 2012 10:12:36 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Stas Malyshev CC: Anthony Ferrara , "internals@lists.php.net" References: <4FFEFBB3.7090507@sugarcrm.com> <4FFEFD81.6020404@lerdorf.com> <4FFEFF71.2060202@sugarcrm.com> In-Reply-To: <4FFEFF71.2060202@sugarcrm.com> X-Enigmail-Version: 1.4.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQko5bcJcJtqbUZoLhfaocOA3uZO39kvfVomxgz1IrN3ijYoiDAsn021g60V+S/VuQS6eo9l Subject: Re: [PHP-DEV] Iterable Type Hint From: rasmus@lerdorf.com (Rasmus Lerdorf) On 07/12/2012 09:46 AM, Stas Malyshev wrote: > Hi! > >> For non-interchangeable types it is already strict by definition. I >> don't see a problem with type hints that make life easier on both the >> caller (by generating better error messages) and the callee (by having >> to write less boilerplate type verification code). > > It doesn't make the life of the caller easier. On the contrary, it makes > each call into a minefield - will it blow up with a system-level error > when you call it? Added bonus of this one is that there's no sure way to > check for it - at least for callable we had is_callable, here we just > have to add boilerplate code for every call. And good luck making them > handle it in an unified way - since it's not library code, then probably > will do each different thing, and about 50% of places will forget it or > not know downstream inserted this surprise into the execution stream. For non-interchangeable types the code is going to blow up anyway. If you pass a MySQL resource to a function that takes a callable and that function does $arg(); the result is a non-catchable fatal error: Fatal error: Function name must be a string Compare to adding 'callable': Catchable fatal error: Argument 1 passed to func() must be callable, resource given This gives quite a bit more info since we now know that it was an argument and specifically which argument it was, what its type was and what it should have been vs. having a fatal from somewhere deep in the function itself. So I disagree with you on it not making life easier for the caller in this specific case where there is no way for the type to be coerced into something that makes sense. -Rasmus