Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83884 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75834 invoked from network); 26 Feb 2015 10:43:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2015 10:43:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=pthreads@pthreads.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=pthreads@pthreads.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pthreads.org from 209.85.192.172 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 209.85.192.172 mail-pd0-f172.google.com Received: from [209.85.192.172] ([209.85.192.172:41547] helo=mail-pd0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/F1-65287-6E8FEE45 for ; Thu, 26 Feb 2015 05:43:51 -0500 Received: by pdno5 with SMTP id o5so12150062pdn.8 for ; Thu, 26 Feb 2015 02:43:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=6m/wg10JtdUP3TCteHIymi2N8bPaTNBVH5Yxq44jDRc=; b=bTpFjoYBIATM+OIyQbL3GovUyWQCElVEY59uNlGSvE2JOTWMQLB00Zej8/UzL04war yhWw7zjYTVZwDO+8/VTsdKLDCh2yb70b5AzD5N0ZJ5vfJVqWlDzOVrVJsf0D2B3GBaZ1 X95nmzjOGILnvssv2YXTE4nJuQ9Jlk7RDzRXk/brJr4sddHlvn18grmQ98ZfsCT05YIT YLqXLozdDH7oG4aKMeamrC779wHWTZnNDTCFWeFUwUNDpbmR3XfK5ZZwBPKFX1eBWb5z pAGLJ9WmfLeOMVBXQcsJrz3mcyvKVqIoEhzuhcPoEUZVB916g6DyBpXAVEqUgwb03V2S TGJQ== X-Gm-Message-State: ALoCoQm0in+q7D3Fry6lMucPnmMofkeYkSzEt/4gII21OCfpD3ESJWpl61eOcsfH5ewyYB+UtVjq MIME-Version: 1.0 X-Received: by 10.70.92.164 with SMTP id cn4mr13639410pdb.110.1424947427575; Thu, 26 Feb 2015 02:43:47 -0800 (PST) Received: by 10.70.49.100 with HTTP; Thu, 26 Feb 2015 02:43:47 -0800 (PST) X-Originating-IP: [86.159.154.191] In-Reply-To: References: Date: Thu, 26 Feb 2015 10:43:47 +0000 Message-ID: To: Benjamin Eberlei Cc: Dmitry Stogov , Anthony Ferrara , PHP Internals Content-Type: multipart/alternative; boundary=047d7b5d87193ea0c6050ffb6dd1 Subject: Re: [PHP-DEV] Strict typing and callback vs declare() From: pthreads@pthreads.org (Joe Watkins) --047d7b5d87193ea0c6050ffb6dd1 Content-Type: text/plain; charset=UTF-8 > The implementation should be simpler and more efficient than using declare(). This can't really be correct, if a call to function mine(int $one, double $two) { } results in three function calls then that's going to cost considerably. I don't like the idea of user function being called, but don't hate the idea of an internal API that allows an extension to implement a type system. It could be much simpler, like turning zend_verify_arg_type into a pointer to a function like we did with gc function. All of this is inferior to dual mode, in my opinion. Cheers Joe On Thu, Feb 26, 2015 at 10:34 AM, Benjamin Eberlei wrote: > On Thu, Feb 26, 2015 at 11:10 AM, Dmitry Stogov wrote: > > > Hi Anthony, > > > > What do you think about using a user level callback for strict type > checks > > instead of declare(). It won't allow changing behavior per file, but this > > has its own cons and pros. > > > > > set_strict_type_checker(function ($class_name, $function_nume, $arg_num, > > $expected_type, $value, $file, $line) { > > ... > > return false; > > }); > > include("orig_index.php"); > > ?> > > > > If callback is not set, arguments are converted according to standard > > rules, if set and returns false - fatal error or exception is thrown. > > > > The implementation should be simpler and more efficient than using > > declare(). > > > > Thanks. Dmitry. > > > > This ruins portability with third party libraries completely. > --047d7b5d87193ea0c6050ffb6dd1--