Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49174 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59687 invoked from network); 29 Jul 2010 19:02:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jul 2010 19:02:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=matthewfonda@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=matthewfonda@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: matthewfonda@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-iw0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:60557] helo=mail-iw0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E3/51-06514-040D15C4 for ; Thu, 29 Jul 2010 15:02:26 -0400 Received: by iwn36 with SMTP id 36so567534iwn.29 for ; Thu, 29 Jul 2010 12:02:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=5TwaqQeE/1PyUM4vBteIVsygp+O0UEG2R5vPvtp5LCU=; b=K5+PMZsDPr4vk+RWNDKNeq7LpyFDtTzTppsEL8Hyl9VEzpR4JuRHkcgl9SV7kGYGzu /4wGmO2DVml5jljeZ/RlmGevGi5AleLCVKFPpxQuwPUPcJwve2mU9HGPQEgsjBBREmnq hC8mgqa0mC5xWw/tvOyNKZDCL2Z+D0Ob9G3X4= 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=n/ugfA/1kYzNAKrE3fjd4NyI4Fyg6qVaYyH4fp0NPiP5eTXgkTWmKm5/cr3FnIfUDz IOiVRwOwkIzWHu89+ZLTcsM3vwkyJ6JDY2T8niP4HbSzpdU/BpeBscmPW48bOjm3bssV M7dksOS6BONZmeSOkjHJykYzrxsPTr2zntCsw= MIME-Version: 1.0 Received: by 10.231.34.135 with SMTP id l7mr329292ibd.148.1280430141737; Thu, 29 Jul 2010 12:02:21 -0700 (PDT) Received: by 10.231.167.85 with HTTP; Thu, 29 Jul 2010 12:02:21 -0700 (PDT) In-Reply-To: References: <7.0.1.0.2.20100729151449.0f884440@zend.com> Date: Thu, 29 Jul 2010 12:02:21 -0700 Message-ID: To: Kalle Sommer Nielsen Cc: Zeev Suraski , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: Re: [PHP-DEV] Type hinting From: matthewfonda@gmail.com (Matthew Fonda) On Thu, Jul 29, 2010 at 8:18 AM, Kalle Sommer Nielsen wrote: > > Hello Zeev > > 2010/7/29 Zeev Suraski : > > With the revived interest in the neighbourhood of type hints in the last few > > days I'm resending this email from a few weeks ago. > > > > In a nutshell, use auto-conversion for scalar type hints, and modify the > > conversion rules throughout PHP to handle 'senseless' conversions that > > result in data loss differently - by emitting E_TYPE. > > > > Zeev > > Ill be very much against adding a new error level for typing, E_NOTICE > or E_WARNING should be *enough* for letting the user know of any data > loss. I don't think it would be a good idea for adding a new error > level for specific language features, if we went to use exceptions for > everything it would however have been a sleek solution but we don't. > > As for which solution we should take, we need a userland vote and a > core vote foreach of the 3 solutions we have atm.: > * Strict typehinting (as whats currently in trunk) > * Weak typehinting (with silent autoconvertion) > * Weak typehinting (that emits warnings/notices/type warnings) > > It would be nice to have such a vote so the coming RM's also have > control over which solution is preferered and eventually why its > preferered. While on the subject of type-hinting, I propose the idea of a "callback" type hint, which accepts anything that is callable. This is useful because it allows a function to be sure a given argument is callable, and can then safely use it to call a function which requires a callback, or safely call it using $f(). I think this also falls in the category of array/Object type hints meaning that it doesn't present the controversies of strict vs. weak, so I think it could be a good candidate for inclusion. I made a patch a few weeks back to do this and can post it if anyone is interested. Best regards, --Matthew