Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80535 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70434 invoked from network); 15 Jan 2015 13:03:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jan 2015 13:03:12 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.172 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.172 mail-we0-f172.google.com Received: from [74.125.82.172] ([74.125.82.172:52935] helo=mail-we0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 56/19-14306-F8AB7B45 for ; Thu, 15 Jan 2015 08:03:12 -0500 Received: by mail-we0-f172.google.com with SMTP id k11so14532589wes.3 for ; Thu, 15 Jan 2015 05:03:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=7rQ7SU2v1sl+X/hZb7zHRRUhkfQVlYOBFmWXTybiyng=; b=cZ/1j3q+PPi++HfZm+6ombrTvjwLNQAKO1r8AwIVr9CCsXRDOEGoj0HvFl+wDMIilR 64bmQeJZ5ZUjXrukB9ODegKg0Z/ZFoZagwMvtH3kUP1Q/9jjdI1mxxOxjPt1QmBariaM 9FZ9HJWIzdnZix8KuVz7701HjZYxQN7+f9UItuHQIs+F15SemofTSPXeoaGuDwcAC0Mq 2PIrHLL9l/Tr3oKER/pRXSvdywSh6gpmVOPK0f7Jf6ME7fxLU4F2NGJA6BnGqxXD+CSc eIlH9SbCzvzZEnMjYecVG9PoonUxqOzQQhmVWF6B38HxrxbjcFnCu7R5ywD2A42Mv8eF m5jQ== X-Received: by 10.180.7.201 with SMTP id l9mr24095630wia.80.1421326987524; Thu, 15 Jan 2015 05:03:07 -0800 (PST) Received: from [192.168.0.172] ([62.189.198.114]) by mx.google.com with ESMTPSA id 18sm1980246wjr.46.2015.01.15.05.03.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jan 2015 05:03:06 -0800 (PST) Message-ID: <54B7BA74.4010708@gmail.com> Date: Thu, 15 Jan 2015 13:02:44 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> <4E2073DE-0951-498C-97BB-DDAC094F11FA@ajf.me> <9a033dd1f223f854e760924d118ab812@mail.gmail.com> <2ae0164cb9b9bf1c974d7a3c60af0466@mail.gmail.com> <6105ea99002e634373c09685310e26a6@mail.gmail.com> In-Reply-To: <6105ea99002e634373c09685310e26a6@mail.gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: rowan.collins@gmail.com (Rowan Collins) Zeev Suraski wrote on 15/01/2015 11:56: > PLUS have the ability to radically > change how it behaves based on a runtime option. It's so bad that we > decided more than a decade ago that we want to refrain from ever introducing > such elements to PHP again (e.g. magic_quotes_runtime), and I'm not sure why > we're even discussing it. Just on this point, I do think declare() is potentially less evil than ini_set() / php.ini. A declare() directive is scoped to a particular section of code, so library authors shouldn't need to care which setting their users prefer, only the version they themselves wish to use. This contrasts completely with things like mbstring.func_overload, which makes shared library code run differently in different configurations. As has been clarified elsewhere on this thread, under this proposal a library author writing function foo(int $foo) will ALWAYS receive an integer, regardless of how that integer is arrived at. Very approximately, the declare() directive effectively gives the caller a choice between two pieces of syntactic sugar, both of which guarantee that the callee's contract will be met: if ( is_int($foo) ) { foo($foo); } else { raise_type_error($foo); } or foo ( (int)$foo ); So, just to repeat, this is NOT like register_globals or mbstring.func_overload, because shared code never needs to handle both settings. That's not to say I'm 100% convinced that this is the right way to go, just that it's not as abominable as some people are making out. Regards, -- Rowan Collins [IMSoP]